Question: Consider the following simple program segment and note how repetitive it is to prompt for the inputs. public static void main ( String [ ]

Consider the following simple program segment and note how repetitive it is to prompt for the inputs.
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("First item: ");
double price = in.nextDouble();
System.out.print("Next item: ");
price = price + in.nextDouble();
System.out.print("Tax rate in percent: ");
double rate = in.nextDouble();
double tax = price * rate /100;
System.out.println("Amount due: "+(price + tax));
}
Rearrange these lines of code into an alternate solution with a reusable helper me
 Consider the following simple program segment and note how repetitive it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!