Code IF fragments which I need help.

I am not sure on how to do these, i got a quiz on them and was wondering if anyone could help.


Write a code fragment that prompts tries to parse an hourly rate of pay from the TextBox named hourlyTxt and stores the result in double variable hourlyRate. If the text cannot be parsed, display "Enter a number". If, however, the value entered is less than minimum wage (currently $7.25) or the rate is $50.00 per hour or more, then display “Invalid Rate”. Otherwise, display “OK”. Write only the relevant statements. Strive to be efficient.


Employees normally earn a commission of 4.5% of gross sales. However, when int variable itemNumber is 100, 200, or 300, they earn 6%. Write a code fragment that will calculate the correct commission amount using double variables grossSales and commission. Write only the relevant statements. Strive to be efficient. [Note: It is intended that you calculate the commision amount not the commision rate.
This is not a homework site. We will not do your homework or quiz for you.
Make an attempt to solve the two problems and post what you have along with any specific questions.

Write a code fragment that will display the value of double variable gpa in the Label named gpaLabel with 3 decimal places of precision.

(what i think is the answer)
gpaLabel.text-gpa.tostring("d3");


Write a code fragment that will display “Good Job” when int variable score is 80 or more, “OK” when score is 70 – 79, and “Needs Work” for any score under 70. Write only the relevant statements. Strive to be efficient.
if (score >=80)
{messagebox.show("Good job");
}
else if(score >=70 && <80)
messagebox.show("OK");
else{
messagebow.show("Needs Work")
}

Write a code fragment that will apply a 10% discount to the value in double variable total when int variable numItems is 5 or more and int variable zone is 1, 3 or 5. Write only the relevant statements. Strive to be efficient. [Note: It is intended that you update the value already in total to reflect the discount only when both conditions are satisfied.

if (numitems >=5 && (zone-=1 || zone-- 3 || zone- 5 ) total*=.9;

Write a code fragment that prompts tries to parse an hourly rate of pay from the TextBox named hourlyTxt and stores the result in double variable hourlyRate. If the text cannot be parsed, display "Enter a number". If, however, the value entered is less than minimum wage (currently $7.25) or the rate is $50.00 per hour or more, then display “Invalid Rate”. Otherwise, display “OK”. Write only the relevant statements. Strive to be efficient.

double number- double.parse.hourlyTxt
if (number <=7.25 || >50)
{
messagebox.show("invalid rate");
}
else{
messagebox.show("OK");}


I would like to see how i am doing this does not have to be exact but i would to see if i am on the right track.
Last edited on
Topic archived. No new replies allowed.