Qbasicnews.com

Full Version: Need help with some stuff..
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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.
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]
Thank so much! Big Grin
Might want to test it first, though.

I just saw a little typo . . .
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
Aga, why did you array the ratings?
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
Code:
Aga, why did you array the ratings?

Makes it easier to change. Blarg.
Quote:...Blarg.
im the one that started saying blarg around here. grrr
did blarg come from blog
Pages: 1 2