Answer to Question #279058 in Java | JSP | JSF for kkkkkk

Question #279058

Ground Beef Value Calculator Different packages of ground beef have different percentages of fat and different costs per pound. Write a program that asks the user for: 1. The price per pound of package "A" 2. The percent lean in package "A" 3. The price per pound of package "B" 4. The percent lean in package "B" The program then calculates the cost per pound of lean (nonfat) beef for each package and writes out which is the best value. INPUT Enter Price per pound package A: 2.89 Percent lean package A: 85 Price per pound package B: 3.49 Percent lean package B: 93 OUTPUT Package A cost per pound of lean:3.4 Package B cost per pound of lean:3.75 Package A is the best value Assume that the two packages will not come out equal in value. Note: the output of the program above should be formatted to 2 decimal places using the method System.out.printf(). Note: Use if and switch Control statement Format of Answer 1. Code 2. Screenshot of codes in editor 3. Output 


1
Expert's answer
2021-12-13T04:25:49-0500
1. Code 



import java.util.Scanner;


public class App {


	/**
	 * The start point of the program
	 * 
	 * @param args
	 * 
	 */
	public static void main(String[] args) {


		Scanner keyBoard = new Scanner(System.in);


		System.out.print("Enter Price per pound package A: ");
		double pricePerPoundPackageA = keyBoard.nextDouble();
		System.out.print("Percent lean package A: ");
		double percentLeanPackageA = keyBoard.nextDouble();
		System.out.print("Price per pound package B: ");
		double pricePerPoundPackageB = keyBoard.nextDouble();
		System.out.print("Percent lean package B: ");
		double percentLeanPackageB = keyBoard.nextDouble();


		double packageACostPerPoundLean = (pricePerPoundPackageA / percentLeanPackageA) * 100.0;
		double packageBCostPerPoundLean = (pricePerPoundPackageB / percentLeanPackageB) * 100.0;
		// OUTPUT
		System.out.printf("Package A cost per pound of lean:%.2f\n", packageACostPerPoundLean);
		System.out.printf("Package B cost per pound of lean:%.2f\n", packageBCostPerPoundLean);
		if (packageACostPerPoundLean < packageBCostPerPoundLean) {
			System.out.println("Package A is the best value");
		} else {
			System.out.println("Package B is the best value");
		}


		keyBoard.close();
	}
}



2. Screenshot of codes in editor




3. Output 



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog