novacaine98
Baseband Member
- Messages
- 53
I have to write a program in Java and it is due by 4:00pm eastern time, today, September 19. Here's what I have to do.
Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
Use if...else statements only for the decision logic.
The user should input information in dialog boxes.
The output should be to the user in a dialog box.
Quantity Discount
0-9 None
10-19 20%
20-49 30%
50-99 40%
100+ 50%
Here's what I have now.
public class Homwork3 {
public static void main ( String [] args )
{
int packages;
String packages = JOptionPane.showInputDialog( "Enter number of packages purchased.");
If (packages >=0 and <=9) {
discount = packages - (packages * 0);
System.out.println("This is the discount for a quantity of zero to nine packages purchased.");
JOption.Pane.showMessageDialog(null, output);
}
else
If (packages >=10 and <=19) {
discount = packages - (packages * .20);
System.out.println("This is the discount for a quantity of ten to nineteen packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=20 and <=49) {
discount = packages - (packages * .30);
System.out.println("This is the discount for a quantity of twenty to forty-nine packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=50 and <=99) {
discount = packages - (packages * .40);
System.out.println("This is the discount for a quantity of fifty to ninety-nine packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=100) {
discount = packages - (packages * .50);
System.out.println("This is the discount for a quantity of one hundred or more packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
}
}
I ran the compiler and it says ')' expected on line 12, which is If (packages >=0 and <=9) {
Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount.
Use if...else statements only for the decision logic.
The user should input information in dialog boxes.
The output should be to the user in a dialog box.
Quantity Discount
0-9 None
10-19 20%
20-49 30%
50-99 40%
100+ 50%
Here's what I have now.
public class Homwork3 {
public static void main ( String [] args )
{
int packages;
String packages = JOptionPane.showInputDialog( "Enter number of packages purchased.");
If (packages >=0 and <=9) {
discount = packages - (packages * 0);
System.out.println("This is the discount for a quantity of zero to nine packages purchased.");
JOption.Pane.showMessageDialog(null, output);
}
else
If (packages >=10 and <=19) {
discount = packages - (packages * .20);
System.out.println("This is the discount for a quantity of ten to nineteen packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=20 and <=49) {
discount = packages - (packages * .30);
System.out.println("This is the discount for a quantity of twenty to forty-nine packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=50 and <=99) {
discount = packages - (packages * .40);
System.out.println("This is the discount for a quantity of fifty to ninety-nine packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
else
If (packages >=100) {
discount = packages - (packages * .50);
System.out.println("This is the discount for a quantity of one hundred or more packages purchased.");
JOption.Pane.showMessageDialog(null, ouput);
}
}
}
I ran the compiler and it says ')' expected on line 12, which is If (packages >=0 and <=9) {