Question: Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the user

Suppose you shop for rice in two different packages. You would like to write a program to compare the cost. The program prompts the user to enter the weight and price of the each package and displays the one with the better price. Here is a sample run:

Enter weight and price for package 1: 50 24.59 PEnter Package 2

has a better price. Enter weight and price for package 1: 50

Enter weight and price for package 1: 50 24.59 PEnter Package 2 has a better price. Enter weight and price for package 1: 50 25 PEnter Enter weight and price for package 2: 25 12.5 JEnter Two packages have the same price.

Step by Step Solution

3.42 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Compare costs Program plan Prompt the user to enter weight and price of two different packages Findi... View full answer

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 Java Programming Questions!