Posts: 2
Threads: 1
Joined: Dec 2003
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?
Posts: 3,368
Threads: 195
Joined: Jan 2003
First, n
ever 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.
Posts: 2
Threads: 1
Joined: Dec 2003
Thank so much!
e, Myself, And Who?
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 4,307
Threads: 63
Joined: May 2003
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
Posts: 1,057
Threads: 156
Joined: Aug 2003
Aga, why did you array the ratings?
Posts: 4,307
Threads: 63
Joined: May 2003
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
Posts: 3,368
Threads: 195
Joined: Jan 2003
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.
Posts: 2,765
Threads: 138
Joined: Nov 2002
Quote:...Blarg.
im the one that started saying blarg around here. grrr
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 1,057
Threads: 156
Joined: Aug 2003