Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with some stuff..
#1
Hey.

I'm having problems understanding how to make a loop i need to make this loop:

INPUT "please enter two numbers separated by a comma: ", num1, num2
¦product = num1 * num2
¦PRINT "the product of "; num1; "and "; num2; "is "; product
¦END

Also, I'm really lost with trying to awnser this question using quickbasic:

Workers at a factory work between 20 and 40 hours per week. They are paid using a rate class. If the rate class is an “A”, the worker makes $10 per hour. If the rate class is a “B”, the worker makes $14 per hour. If the rate class is a “C”, the worker makes $18 per hour. Ask the user to enter the employee’s name, hours worked and pay class. Calculate the appropriate gross pay. Print to the screen, the workers name, hours worked, rate class and gross pay.

Any help would be greatly appreciated.
e, Myself, And Who?
Reply
#2
First, never make a thread without checking your post for spelling, grammar, and especially PERIOD OMISSIONS!

Second, use the code tags.. "[ code]" and "[/ code]"... without the spaces.

Third,
Code:
DO
INPUT "please enter two numbers separated by a comma: ", num1, num2
product = num1 * num2
PRINT "the product of "; num1; "and "; num2; "is "; product
INPUT "Again?"; q$
q$ = LCASE$(q$)
IF q$ = "y" THEN EXIT DO
IF q$ = "yes" THEN EXIT DO
LOOP
END

Fourth, separate problems . . it will help you out:

Quote:Workers at a factory work between 20 and 40 hours per week.

OK.

They are paid using a rate class:
If the rate class is an “A”, the worker makes $10 per hour.
If the rate class is a “B”, the worker makes $14 per hour.
If the rate class is a “C”, the worker makes $18 per hour.

OK.

Ask the user to enter:
employee’s name
hours worked
pay class.

OK.

Calculate the appropriate gross pay.

OK.

Print to the screen:
the worker's name
hours worked
rate class
gross pay.

I'm substituting "rate class / pay class" for RATING, because that's actually a word that makes sense..

Code:
DEFINT A-Z
DIM Rating (1 TO 3)
Rating(1) = 10
Rating(2) = 14
Rating(3) = 18

INPUT "worker's name?"; name$

DO
INPUT "hours worked?"; hoursWorked
IF hoursWorked > 40 THEN EXIT DO
IF hoursWorked < 20 THEN EXIT DO
LOOP

DO
INPUT "worker's rating?"; letter$
SELECT CASE letter$
CASE "A": n = 1: EXIT DO
CASE "B": n = 2: EXIT DO
CASE "C": n = 3: EXIT DO
END SELECT
LOOP
pay = Rating(n) * hoursWorked

PRINT "name"; workerName$
PRINT "hours worked"; hoursWorked$
PRINT "rating"; letter$
PRINT "gross pay"; pay

That is all.

[/leaves the thread]
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#3
Thank so much! Big Grin
e, Myself, And Who?
Reply
#4
Might want to test it first, though.

I just saw a little typo . . .
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#5
Aga, dont jump all over him like that.

Darkist, You must be a little more organised to get a program done. Aga was 100% right to tell you to separate your problem in point form.

BTW I personally dont like aga's loop. I like mine better:
Code:
DO
   Print "do you want to continue?"
   ans$ = input$(1)
   if lcase$(ans$) = "n" then exit do
LOOP
Reply
#6
Aga, why did you array the ratings?
Reply
#7
Hmm...he could have written this...
Code:
DO
INPUT "worker's rating?"; letter$
SELECT CASE letter$
CASE "A": n = 1: EXIT DO
CASE "B": n = 2: EXIT DO
CASE "C": n = 3: EXIT DO
END SELECT
LOOP
pay = Rating(n) * hoursWorked

as...

Code:
DO
INPUT "worker's rating?"; letter$
SELECT CASE letter$
CASE "A": pay = 10 * hoursWorked: EXIT DO
CASE "B": pay = 14 * hoursWorked : EXIT DO
CASE "C": pay = 18 * hoursWorked : EXIT DO
END SELECT
LOOP
Reply
#8
Code:
Aga, why did you array the ratings?

Makes it easier to change. Blarg.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#9
Quote:...Blarg.
im the one that started saying blarg around here. grrr
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#10
did blarg come from blog
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)