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

I want the information put into the scanner to be populated into the public Plum

ID: 3807908 • Letter: I

Question

I want the information put into the scanner to be populated into the public Plumber and then be output at the end with the bill. Below is what I have so far which doesn't work - some of it is just a guess. If you could explain why you made changes you did or how you were able to have the information populated that would be great!

import java.util.Scanner;

public class Plumber
{

   public static void main(String[] args)
   {

   double cFlood1 = 300;
   double cFlood2 = 500;
   double cFlood3 = 750;
   double cPipe1 = 50;
   double cPipe2 = 70;
   double cPipe3 =100;
   double roomsCost;
   double pipesCost;
   int cost = 0;
   int service;
   int numberRooms;
   int numberPipes;
   String burstPipes ="";

      public Plumber(int srv, int numRms, int bstPipes, String numPipes)
    
      {    
      service = srv;
      numberRooms = numRms;
      burstPipes = bstPipes;
      numberPipes = numPipes;
      }
    
    
    



   Scanner userInput = new Scanner(System.in);
    
   System.out.print(" Please enter 1"+ "if there was flood damage>>");
   service = userInput.nextInt();
   System.out.print(" How many rooms were flooded - 1" + "2" + "3" + "or more >>");
   numberRooms = userInput.nextInt();
   System.out.print(" Were there any burst pipes? Please enter Y" + "or" + "N >>");
   burstPipes = userInput.nextLine();
   System.out.print(" How many pipes burst? - 1" + "2" + "3" + "or more>>");
   numberPipes = userInput.nextInt();
   srv.service;
   numRms.numberRooms;
   bstPipes.burstPipes;
   numPipes.numberpipes;
   return srv, numRms, bstPipes, numPipes;


   Plumber firstCustomer = new Plumber(srv, numRms, bstPipes,numPipes)


       public static void display()
          {
            String p1 = " no rooms flooded";
            String p2 = "1 room flooded";
            String p3="with 2 rooms flooded";
            String p4="with 3 or more rooms flooded"
            String p5=" no burst pipes apparent ";
            String p6=" and 1 burst pipe apparent ";
            Stromg p7=" and 2 burst pipes apparent ";
            String p8=" and 3 burst pipes apparent ";
                
            
                
               if(service == 1)
                
                   {
                        System.out.println(" You have stated that the damage to your house involves a natural flood.");
                         
                            switch(NumberRooms)
                            {
                                case 0:
                                    System.out.printf("%s",p1);
                             
                                case 1:
                                    roomsCost += cFlood1;
                                    System.out.printf("%s",p2);
                                    break;
                                case 2:
                                    roomsCost += cFlood2;
                                    System.out.printf("%s",p3);
                                    break;
                                case 3:
                                    roomsCost += cFlood3;
                                    System.out.printf("%s",p4);
                                    break;
                                  
                                }
                                
                                  
                    if(burstPipes == "Y" || burstPipes == "y")
                         {
                            switch(burstPipes)
                            {
                              
                                case 0:
                                     System.out.printf("%s",p5);
                                     break;
                                case 1:
                                    pipesCost += cPipe1;
                                    System.out.printf("%s",p6);
                                    break;
                                case 2:
                                    pipesCost += cPipe2;
                                    System.out.printf("%s",p7);
                                    break;
                                case 3:
                                    pipesCost += cPipe3;
                                    System.out.printf("%s",p8);
                            }
                          
                      
                        }
                      
                    }
                 
                }
               
                
               
                    
                  
public void ComputePrice()
   {
      if(service ==1) //this (w two nested ifs) could be: if(needSrvc==1 && (!ttlRoom==0))
      {
      
         cost = roomsCost + pipesCost;
       
         if(!(roomsCost==0))
            System.out.printf(" %s Room Flood Repair = $%s ",numberRooms,roomsCost);
       
         if(!(pipesCost==0))
            System.out.printf("%s Pipe Repair = $%s ",numberPipes,pipesCost);
       
         System.out.printf("                 ------------ " +
         "Estimated Amount Due: $%s ",cost);
       
         System.out.print("** Please Have This Amount Available -" +
         "   Fees Are Due At Time Of Service.    This Is An Estimate Only." +
         " Final Bill Will Be Based On Onsite Evaluation." +
         "    All Work Will Be Discussed And Agreed Upon Prior To Repairs. ** ");
      }
      /
      else System.out.printf("If you need services, please come visit us again. ");          
                 
             
    }          
                
}

Explanation / Answer


import java.util.Scanner;

                
public class Plumber
{
    //class variable declarations
    //modified
    int service;
    int numberRooms;
    int burstPipes;
    int numberPipes;
    double roomsCost;
   double pipesCost;
    private int NumberRooms;
    double cFlood1 = 300;
   double cFlood2 = 500;
   double cFlood3 = 750;
   double cPipe1 = 50;
   double cPipe2 = 70;
   double cPipe3 =100;
   double cost;
   String BurstPipes ="";

    private Plumber(int srv, int numRms, int bstPipes, int numPipes)
    {    
      service = srv;
      numberRooms = numRms;
      burstPipes = bstPipes;
      numberPipes = numPipes;
    }

    private Plumber(int service, int numberRooms, String burstPipes, int numberPipes) {
       // throw new UnsupportedOperationException("Not yet implemented");
        this.service = service;
      this.numberRooms = numberRooms;
      this.BurstPipes = burstPipes;
      this.numberPipes = numberPipes;
    }


  
     public void display()
          {
            String p1 = " no rooms flooded";
            String p2 = "1 room flooded";
            String p3="with 2 rooms flooded";
            String p4="with 3 or more rooms flooded";////modified
            String p5=" no burst pipes apparent ";
            String p6=" and 1 burst pipe apparent ";
            String p7=" and 2 burst pipes apparent ";//modified
            String p8=" and 3 burst pipes apparent ";
                
            
                
               if(service == 1)
                
                   {
                        System.out.println(" You have stated that the damage to your house involves a natural flood.");
                         
                            switch(NumberRooms)
                            {
                                case 0:
                                    System.out.printf("%s",p1);
                             
                                case 1:
                                    roomsCost += cFlood1;
                                    System.out.printf("%s",p2);
                                    break;
                                case 2:
                                    roomsCost += cFlood2;
                                    System.out.printf("%s",p3);
                                    break;
                                case 3:
                                    roomsCost += cFlood3;
                                    System.out.printf("%s",p4);
                                    break;
                                  
                                }
                                
                                  
                    if(BurstPipes.equals("Y") || BurstPipes.equals("y"))
                         {
                            switch(burstPipes)
                            {
                              
                                case 0:
                                     System.out.printf("%s",p5);
                                     break;
                                case 1:
                                    pipesCost += cPipe1;
                                    System.out.printf("%s",p6);
                                    break;
                                case 2:
                                    pipesCost += cPipe2;
                                    System.out.printf("%s",p7);
                                    break;
                                case 3:
                                    pipesCost += cPipe3;
                                    System.out.printf("%s",p8);
                            }
                          
                      
                        }
                      
                    }
                 
                }
   
   
   public void ComputePrice()
   {
      if(service ==1) //this (w two nested ifs) could be: if(needSrvc==1 && (!ttlRoom==0))
      {
      
         cost = roomsCost + pipesCost;
       
         if(!(roomsCost==0))
            System.out.printf(" %s Room Flood Repair = $%s ",numberRooms,roomsCost);
       
         if(!(pipesCost==0))
            System.out.printf("%s Pipe Repair = $%s ",numberPipes,pipesCost);
       
         System.out.printf("                 ------------ " +
         "Estimated Amount Due: $%s ",cost);
       
         System.out.print("** Please Have This Amount Available -" +
         "   Fees Are Due At Time Of Service.    This Is An Estimate Only." +
         " Final Bill Will Be Based On Onsite Evaluation." +
         "    All Work Will Be Discussed And Agreed Upon Prior To Repairs. ** ");
      }
    
      else System.out.printf("If you need services, please come visit us again. ");          
                 
             
    }

   
   
  
   public static void main(String[] args)
   {

   double cFlood1 = 300;
   double cFlood2 = 500;
   double cFlood3 = 750;
   double cPipe1 = 50;
   double cPipe2 = 70;
   double cPipe3 =100;
   double roomsCost;
   double pipesCost;
   int cost = 0;
   int service;
   int numberRooms;
   int numberPipes;
   String burstPipes ="";

    
    
    
    



   Scanner userInput = new Scanner(System.in);
    
   System.out.print(" Please enter 1"+ "if there was flood damage>>");
   service = userInput.nextInt();
   System.out.print(" How many rooms were flooded - 1" + "2" + "3" + "or more >>");
   numberRooms = userInput.nextInt();
   burstPipes = userInput.nextLine();
   System.out.print(" Were there any burst pipes? Please enter Y" + "or" + "N >>");
   burstPipes = userInput.nextLine();
   System.out.print(" How many pipes burst? - 1" + "2" + "3" + "or more>>");
   numberPipes = userInput.nextInt();

   /*
   srv.service;
   numRms.numberRooms;
   bstPipes.burstPipes;
   numPipes.numberpipes;
   return srv, numRms, bstPipes, numPipes;

   */
   //modified
   Plumber firstCustomer = new Plumber(service, numberRooms, burstPipes,numberPipes);//

   firstCustomer.ComputePrice();
   firstCustomer.display();

    
               
                
               
                    
   }              
        
}

//i have cleared your errors, but didn't changed your logic, change your logic to get desired output

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