Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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");

}

}

image text in transcribedimage text in transcribed
(:3 Chapr x H MD3_GADD2213_07_SE_. x KB Raum|mereduyaox 3: Kg] FewSlepsSeparalleyDuf xYG inmlnnpane-Google See x\\D o X C ' 3 Secure ' hpsu'lappboxcom/s/hSlquBlhlqungyxabpukc7y73yr 3} E Apps E1! SmarlBuok A DerellconofDuty:.' W My Recently Vlewed F'llea > MULGADuznspxsgcoapdv Ge to My Accuunt 1m 5mm Average Lemar Glade 90100 A 5039 B 70779 E my I) Bcflnw 60 |-' 5. Man Ind WEIEHI . Ii": mlmum an obit-ct: man in kilngraml and its wright in Ncwlona. If you knnw [up amuunl ufnnthat an uhim nu yum can mkulm in wcigm, in NW\C3 Chapma x H MD3_GADD2213_07_SE_. x KB Reunts|metedbyamt 3: Kg] FewStepsstepatateyout xYG inminnpane-Goagle Se; x\\D e X C ' 3 Secure ' hpswapptboxcom/s/hS'quE'hlqungyxabpukc7y73yr 3} E Apps E1! SmarlBuok A DerellconofDuty:.' W My RecenLly matted F'Mes > MULGAD02113,07,5E,c03.pdv \\ Ga to My Accnunt pmgram would display: - Andy Chenil- mutt IL Will\" A sufrwam {I'llp'ally nL-Eh apeckagl'lhar mutt; lutwy. Quantity distant\": ant-gm: mm mgmxhcldhwmglahlnt Quanlity DiImIllll 1049 20% 2D49 30% \\ .1me t. Q m. my...' \\ \\ pragnllnlnaCl'lallElgB um Quantity Diaml' SW99 40% IDCI Dr mn- 50% Write a program that nah the M [0 enter the numhcr 0! packages purchased. Th: pwam Ihoukl tttttt diiplay lhc amwlll nl [hcdiacoum nutty) and the total mun: olthc gmhm aftL-r \"IE dinmlmt 9. Shippil' lil'gnl 11m I-lst might Shipping (human)! charges (In: lu|luwing Ian's: Weigh! rming: ampetsuu Mile! Shipped 2 ptmttusut In: sun) Ovl'f 2mm: but nal lnnrl' than 6 puttmk 52.29 mm a pnund: but not mm man 10 puundt 13.70 v E Type here to search

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions