Question

2.1 Area of a Pizza Pie Pizzas in the USA are just big circles of bread, cheese, and tomato sauce, mea- sured by the size of their diameter in inches. You can use that to get the area of the circle, which is measured in square inches. Write a method which takes in the diameter of a circle and returns the area. Remember: d=2r a=π 2.2 Computing the Price per Square Inch Figuring out the price per square inch should be its own method. Given the area of a circle in square inches and the price, the method should return the price per square inch. 2.3 Interactivity Your program should be interactive. This means that the program should ask the user to enter the size of the pizza and the price.4 All the input from console and output to the user should happen on in main


media%2Fc77%2Fc7791119-ea62-434c-ade5-5a

Need help with this problem by using JAVA and in second picture I have circled the Extra Credit, if possible. Please help and Thank you so much in advance.!
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class Pizza{

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Enter the number of pizzas: ");

int noOfPizzas = in.nextInt();

double cost, cheapestPizza = 99999;

while(noOfPizzas > 0){

System.out.print("\nEnter the size of pizza: ");

double size = in.nextDouble();

System.out.print("Enter the price of pizza: ");

double price = in.nextDouble();

cost = getCost(size, price);

if(cost < cheapestPizza)

cheapestPizza = cost;

noOfPizzas--;

}

System.out.println("The cheapest pizza is $" + cheapestPizza);

}

private static double getCost(double size, double price) {

return size * price;

}

}

Enter the number of pizzas: 3 Enter the size of pizza: 5 Enter the price of pizza: 10 Enter the size of pizza: 7 Enter the pr

**Comment for any further queries.

Add a comment
Know the answer?
Add Answer to:
Need help with this problem by using JAVA and in second picture I have circled the...
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
  • A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices...

    A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices a pizza of any aize can be divided into, and hoe many pizzas should be ordered for a party. The program will assume each person at the party will eat 3 slices of pizza each. The program should prompt the user for the diameter of the pizzas they wish to order. it will also ask the user for the number of people who will...

  • I've written this program in C++ to compare 2 pizzas using classes and it works fine....

    I've written this program in C++ to compare 2 pizzas using classes and it works fine. I need to convert it to java using both buffered reader and scanner and can't get either to work. //C++ driver class for Pizza program #include <iostream> #include <string> #include <algorithm> #include <iomanip> using std::cout; using std::cin; using std::string; using std::endl; using std::transform; using std::setprecision; using std::ios; using std::setiosflags; #include "Pizza.h" int main() {             char response = 'Y';             while (response == 'Y')...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • I need to write a paint job estimator program in python. I have most of it...

    I need to write a paint job estimator program in python. I have most of it down but i keep getting errors and I dont know how to fix it or what im doing worng specs: A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter...

  • ******** IN JAVA ********* I have a program that I need help debugging. This program should...

    ******** IN JAVA ********* I have a program that I need help debugging. This program should ask a user to input 3 dimensions of a rectangular block (length, width, and height), and then perform a volume and surface area calculation and display the results of both. It should only be done using local variables via methods and should have 4 methods: getInput, volBlock, saBlock, and display (should be void). I have most of it written here: import java.util.*; public class...

  • Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a...

    Hello can someone help me in my code I left it as comment  task #0, task#1, task#2a and task#2b the things that I am missing I'm using java domain class public class Pizza { private String pizzaCustomerName; private int pizzaSize; // 10, 12, 14, or 16 inches in diameter private char handThinDeep; // 'H' or 'T' or 'D' for hand tossed, thin crust, or deep dish, respecitively private boolean cheeseTopping; private boolean pepperoniTopping; private boolean sausageTopping; private boolean onionTopping; private boolean...

  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

  • PLEASE HELP this is the last part of my lab and I need help ): add comments please (: if it is to...

    PLEASE HELP this is the last part of my lab and I need help ): add comments please (: if it is too difficult you do not have to do part 3 but it would be greatly appreciated if you do ! Obtain example code files Circle.java, Shape.java, CircleShape2.java, Sphere.java, and CircleShapeApp.java from the downloaded files in Ch8. Compile and execute the example and understand the polymorphism it performs. (I have copied and pasted all of these files below) Modify...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • Written in Java I have an error in the accountFormCheck block can i get help to...

    Written in Java I have an error in the accountFormCheck block can i get help to fix it please. Java code is below. I keep getting an exception error when debugging it as well Collector.java package userCreation; import java.io.IOException; import java.net.URL; import java.util.ResourceBundle; import java.util.regex.Matcher; import java.util.regex.Pattern; import javafx.event.ActionEvent; import javafx.fxml.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.text.Text; import javafx.stage.*; public class Controller implements Initializable{ @FXML private PasswordField Password_text; @FXML private PasswordField Confirm_text; @FXML private TextField FirstName_text; @FXML private TextField LastName_text;...

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