Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I want to turn this peice of code into a class? Can anyone help me do that? Its

ID: 660971 • Letter: I

Question

I want to turn this peice of code into a class? Can anyone help me do that? Its a pretty simple code that is for my program that lets you build and order pizza. I want this to be able to give the "customer" a estimate of time it wil take to make their pizza, so i created a random number that spits minutes in an hour. If ther pizza takes longer than 45 minutes than you get it for free otherwise it will just diplay the time. I have this code below that works fine i just want need it to be a method, and i dont really know how to do that?

          System.out.println(" If your pizza takes longer than 45 minutes");
          System.out.println(" then you get it free!");
          double time = Math.random();
          minutes = time*60;
          double minRound = Math.round(minutes);
          if(minRound>=45)
          {
             System.out.println("Your pizza is estimated to take " + minRound + " minutes,");
             System.out.println("Lucky you, your pizza if free today!");
            
          }
          else
          {
             System.out.println("Your pizza is estimated to take " + minRound + " minutes,");
             System.out.println("See ya soon!");
          }

Explanation / Answer

Pizza.java

class User
{
           //global variables declartion
            public double time = Math.random();
            public double minutes = time*60;
            public double minRound = Math.round(minutes);
           
             
             public void deliveryTime()
             {
               System.out.println("If your pizza takes longer than 45 minutes");
                 System.out.println("then you get it free!");
            
                if(minRound>=45)
                {
                    System.out.println("Your pizza is estimated to take " + minRound + " minutes,");
                    System.out.println("Lucky you, your pizza if free today!");
                
                }
                else
                {
                    System.out.println("Your pizza is estimated to take " + minRound + " minutes,");
                    System.out.println("See ya soon!");
                }
   }

}

class Pizza
{
   public static void main (String[] args)    {
       User user=new User(); //creating object to the class and calling it from main.
       user.deliveryTime();
   }
}

output:

If your pizza takes longer than 45 minutes
then you get it free!
Your pizza is estimated to take 30.0 minutes,
See ya soon!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote