Question

I have most of the code but I do not know how to print the report for 3 circles. Example of what output should look like is attached. PPrompt the user to enter 2 price va tues and then redd the vatues Trom Standaro ihput System.out.println(Enter the 2 unit prices of the materials to compare: ) pricel stdin.nextDouble() price2 = stdin.nextDouble(); //calculate the circumference of each circle using the PI constant in the math Library circumference! = Math.PI * diameter!; circumference2-Math.PI diameter2; circumference3 = Math.PI * diameter3; areal Math.PI Math.pow (diameter1/2, 2); area2 Math.PI Math.pow(diameter2/2, 2); area Math.PI * Math.pow(diameter3/2, 2); System.out.print ln) System.out.print ln(Here is your cost comparison report:) System.out.print In) Systen. out.println(Circle .. + Circumference .. + Cost of Material! .. + Cost of Material2 Area) //ADD 3 STATEMENTS TO PRINT THE REPORT FOR EACH CIRCLE

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i attached screenshot of code and output. go through it. this will help you. please provide your valuable feedback.

Code:

import java.util.Scanner public class Material ublic atatic void main(String args) Scanner sc=new Scanner (System.in); doubleOutput:

Enter the 3 diameter values of the garden: 25.5 12.25 Enter the 2 unit prices of materials to compare: 5.95 9.90 Here 13 your//Code

import java.util.Scanner;

public class Material {

public static void main(String[] args) {

Scanner sc=new Scanner(System.in);

double diameter1,diameter2,diameter3,circumfrance1,circumfrance2,circumfrance3;

double price1,price2,area1,area2,area3;

System.out.println("Enter the 3 diameter values of the garden: ");

diameter1=sc.nextDouble();

diameter2=sc.nextDouble();

diameter3=sc.nextDouble();

System.out.println("Enter the 2 unit prices of materials to compare: ");

price1=sc.nextDouble();

price2=sc.nextDouble();

circumfrance1=Math.PI*diameter1;

circumfrance2=Math.PI*diameter2;

circumfrance3=Math.PI*diameter3;

area1=Math.PI*Math.pow(diameter1/2, 2);

area2=Math.PI*Math.pow(diameter2/2, 2);

area3=Math.PI*Math.pow(diameter3/2, 2);

System.out.println();

System.out.println("Here is your cost comprison report: ");

System.out.println();

System.out.println("Circle\tCircumference\tCost of Material1\tCost of Material2\tArea");

System.out.println("A\t"+(String.format("%.2f",circumfrance1))+"\t\t"+(String.format("%.2f",circumfrance1*price1))

+"\t\t\t"+(String.format("%.2f",circumfrance1*price2))+"\t\t\t"+(String.format("%.2f",area1)));

System.out.println("B\t"+(String.format("%.2f",circumfrance2))+"\t\t"+(String.format("%.2f",circumfrance2*price1))

+"\t\t\t"+(String.format("%.2f",circumfrance2*price2))+"\t\t\t"+(String.format("%.2f",area2)));

System.out.println("C\t"+(String.format("%.2f",circumfrance3))+"\t\t"+(String.format("%.2f",circumfrance3*price1))

+"\t\t\t"+(String.format("%.2f",circumfrance3*price2))+"\t\t\t"+(String.format("%.2f",area3)));

}

}

Add a comment
Know the answer?
Add Answer to:
I have most of the code but I do not know how to print the report...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT