1. Engineering
  2. Computer Science
  3. i want the information put into the scanner to be...

Question: i want the information put into the scanner to be...

Question details

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("\nPlease enter 1"+ "if there was flood damage>>");
   service = userInput.nextInt();
   System.out.print("\n How many rooms were flooded - 1" + "2" + "3" + "or more >>");
   numberRooms = userInput.nextInt();
   System.out.print("\n Were there any burst pipes? Please enter Y" + "or" + "N >>");
   burstPipes = userInput.nextLine();
   System.out.print("\n 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="\n no burst pipes apparent\n";
            String p6="\n and 1 burst pipe apparent\n";
            Stromg p7="\n and 2 burst pipes apparent\n";
            String p8="\n and 3 burst pipes apparent\n";
                
            
                
               if(service == 1)
                
                   {
                        System.out.println("\nYou 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("\n%s Room Flood Repair = $%s\n",numberRooms,roomsCost);
       
         if(!(pipesCost==0))
            System.out.printf("%s Pipe Repair = $%s\n",numberPipes,pipesCost);
       
         System.out.printf("                 ------------\n" +
         "Estimated Amount Due: $%s\n\n",cost);
       
         System.out.print("** Please Have This Amount Available -" +
         "   Fees Are Due At Time Of Service.\n   This Is An Estimate Only." +
         " Final Bill Will Be Based On Onsite Evaluation." +
         "\n   All Work Will Be Discussed And Agreed Upon Prior To Repairs. **\n\n");
      }
      /
      else System.out.printf("If you need services, please come visit us again.\n\n");          
                 
             
    }          
                
}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution