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

Java homework There is a budget assigned to the covering of the floor. There are

ID: 3572759 • Letter: J

Question

Java homework

There is a budget assigned to the covering of the floor. There are four options for floor cover (Ceramic Tile = 1; Hardwood = 2, Carpet = 3; and linoleum tile = 4) each with a cost per square foot. In addition the customer has a preference for which covering they would like. The program will ask for input and read in the budget in dollars and cents, the cost per square foot for each of the different floor options and also ask for which one the customer prefers where 0 means the customer does not care and 1-4 if they have a specific preference.

The program will then, based upon the square footage calculation, check if the users preference can be afforded (Hint use Switch statement but OK to just use IF/ELSE), if not or the user selects “0” not caring, the program will start with the most expensive and check each flooring type until it finds the most expensive flooring that can be afforded. The program will output the type of flooring selected or a message that given the budget no flooring is affordable.

For all three renovation projects from Project 1 use Tile= $4.00 /sq ft; Wood = $3.00/ sq ft; Carpet = $2.00/ sq ft and linoleum = $1.00/sq ft).

Use the following as the budget and preference:

Budget/preference

Renovation 1

Renovation 2

Renovation 3

User preference

0

1

3

Budget

255.00

250.00

400.00

so let's say the floor space is : length * width;( any number); the budget could be llike the image above but any budget is better. I tried to do it , but my main problem is the part where the program will choose the highest possible price affordable. ( I have to use if/ else statements and/or switch statements.)

What i have so far:

double floor = lenght * width;

System.out.println(" choose budget ");
   double budget = getInfo.nextDouble();
   System.out.println(" price per square foot Tile= $4.00 /sq ft; Wood = $3.00/ sq ft; Carpet = $2.00/ ; linoleum = $1.00/sq ft");
     
   int tile= 4; int wood= 3; int carpeting = 2 ;
   int linoleum = 1;
     
   System.out.println(" choose decoration Ceramic Tile = 4; Hardwood = 3, Carpet = 2; and linoleum tile = 1 ");
  
   int decoration = getInfo.nextInt();
   // create an equation of the space of the floor times the material of the decoration.
  
   double priceOfFloor= floor * decoration;
     
  
   // The program will output the type of flooring
   //selected or a message that given the budget no flooring is affordable.


   switch ( decoration) {
  
   case 1 :
       if ( budget >= priceOfFloor) {System.out.println(" your selected option " + decoration);
       }
      
      
       else if ( budget<= priceOfFloor){
           if ( budget <= floor* tile) {   
                 
               System.out.println(" your highest option is " + tile + " Tile");}
             
           else if ( budget <= floor * wood) {
               System.out.println(" your highest option is " + wood + " Wood");}
                 
             
           else if ( budget <=floor *carpeting){
               System.out.println(" your highest option is " + carpeting + " carpet ");}
             
           else if ( budget <= floor * linoleum){
                 
          System.out.println(" your highest option is " + linoleum + " linoleum");}
           }
      
       break;
  
   case 2:
       if ( budget >= priceOfFloor) {System.out.println(" you selected option " + decoration);
       }
      
       else if ( budget<= priceOfFloor){
       if ( budget <= floor* tile) {   
             
           System.out.println(" your highest option is " + tile + " Tile");}
         
       else if ( budget <= floor * wood) {
           System.out.println(" your highest option is " + wood + " Wood");}
             
         
       else if ( budget <=floor *carpeting){
           System.out.println(" your highest option is " + carpeting + " carpet ");}
         
       else if ( budget <= floor * linoleum){
             
        System.out.println(" your highest option is " + linoleum + " linoleum");}
       }
      
      
       break;
   case 3:
       if ( budget >= priceOfFloor) {System.out.println(" you selected option " + decoration);}
      
       else if ( budget<= priceOfFloor){
           if ( budget <= floor* tile) {   
                 
               System.out.println(" your highest option is " + tile + " Tile");}
             
           else if ( budget <= floor * wood) {
               System.out.println(" your highest option is " + wood + " Wood");}
                 
             
           else if ( budget <=floor *carpeting){
               System.out.println(" your highest option is " + carpeting + " carpet ");}
             
           else if ( budget <= floor * linoleum){
                 
          System.out.println(" your highest option is " + linoleum + " linoleum");}
           }
              
       break;
   case 4 :
       if ( budget >= priceOfFloor) {System.out.println(" you selected option " + decoration);}
      
       else if ( budget<= priceOfFloor){
           if ( budget <= floor* tile) {   
                 
               System.out.println(" your highest option is " + tile + " Tile");}
             
           else if ( budget <= floor * wood) {
               System.out.println(" your highest option is " + wood + " Wood");}
                 
             
           else if ( budget <=floor *carpeting){
               System.out.println(" your highest option is " + carpeting + " carpet ");}
             
           else if ( budget <= floor * linoleum){
                 
          System.out.println(" your highest option is " + linoleum + " linoleum");}
           }
          
       break;
   case 0:
       if ( budget <= floor* tile)    {
             
           System.out.println(" your highest option is " + tile + " tile");
       }
       else if ( budget <= floor * wood){
           System.out.println(" your highest option is " + wood + " wood") ;
             
       }
       else if ( budget <=floor *carpeting){
           System.out.println(" your highest option is " + carpeting + " carpet");
       }
       else if ( budget <= floor * linoleum){
             
           System.out.println(" your highest option is " + linoleum + " linoleum");
       }
       break;
   }

Budget/preference

Renovation 1

Renovation 2

Renovation 3

User preference

0

1

3

Budget

255.00

250.00

400.00

Explanation / Answer

Hey there, as far i can see this question is just to find greatest of the four numbers for which we can simply use the following code,

for instance say we have four variables a,b,c,d which contains the rate of flooring as in your case, we want to display the value which is maximum and is under budget , so firstly we will check weather all are in budget and then find the maximum of remaining.

***************Solution Starts***************

double floor = lenght * width;

System.out.println(" choose budget ");
   double budget = getInfo.nextDouble();
   System.out.println(" price per square foot Tile= $4.00 /sq ft; Wood = $3.00/ sq ft; Carpet = $2.00/ ; linoleum = $1.00/sq ft");
      
System.out.println(" choose decoration Ceramic Tile = 4; Hardwood = 3, Carpet = 2; and linoleum tile = 1 ");
  
   int decoration = getInfo.nextInt();

double a,b,c,d;


//Compute price of all types first.

a=floor*4; //priceoffloor_Tile

b=floor*3;//priceoffloor_Wood

c=floor*2;//priceoffloor_Carpet

d=floor*1;//priceoffloor_Linolium

switch(decoration)

{
case 0:

if(a<=budget)
System.out.println("your highest option is Tile");

else if(b<=budget)
System.out.println("your highest option is Wood");

else if(c<=budget)
System.out.println("your highest option is Carpet");

else if(d<=budget)
System.out.println("your highest option is linoleum");

else

System.out.println("Not Possible at this Budget");
break;

case 1:

if(a<=budget)
System.out.println("your highest option is Tile");

else

System.out.println("Not Possible at this Budget");
break;

case 2:

if(b<=budget)
System.out.println("your highest option is Wood");

else

System.out.println("Not Possible at this Budget"):


break;

case 3:

if(a<=budget)
System.out.println("your highest option is Carpet");

else

System.out.println("Not Possible at this Budget"):


break;

case 4:

if(a<=budget)
System.out.println("your highest option is Linoleum");

else

System.out.println("Not Possible at this Budget"):


break;

}

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