Question
I need help with number 8. I am suppose to use an if statement. I upload my code in jgrasp but still shows up error.
I need help with number 8. I am suppose to use an if statement. I upload my code in jgrasp but still shows up error. please edit and fix what i am doing wrong.
import java.util.Scanner;
public class Question_8_Ch_3
{
public static void main(String[]args)
{
Scanner input = new Scanner (System.in);
final int price = 99;
System.out.println("Enter the quanity you wish to purchase");
int quantity = input.nextIn();
double discount;
double pay;
double ActualPurchase;
if (quantity>=100)
{
pay = price*quantity;
discount = pay*0.5;
ActualPurchase = pay-discount;
System.out.println("The discount is" +discount+ "and you will pay" +ActualPurchase);
}
else
if((quantity>=20)&&(quantity
{
pay = price*quantity;
discount = pay*0.4;
ActualPurchase = pay-discount;
System.out.println("The discount is" +discount+ "and you will pay" +ActualPurchase);
}
else
if((quantity>=20))&&(quantity
{
pay = price*discount;
discount = pay*0.3;
ActualPurchase = pay-discount;
System.out.println("The discount is" +discount+ "and you will pay" +ActualPurchase);
}
else
if quantity>=10)&&(quantity
{
pay = price*quantity;
discount = pay*0.2;
ActualPurchase = pay-discount;
System.out.println("The discount is" +discount+ "and you will pay" +ActualPurchase);
}
else
System.out.println("The quatity is too small to be purchased");
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started