cant figure out how to add 20 to variables if it equals one

cant figure out how to add $20 to variables if it equals one of the three: pit, rott, or dob

also need total of all totals tried using \"for\" loop but its not coming out right

here is what i have so far

import java.io.File; // Importing respective packages
import java.io.FileNotFoundException;
import java.util.Scanner;

class file{public static void main(String[] args) throws FileNotFoundException
   {
      // Primitive variables for holding values for calulation.
  
      int weight = 0;
      int numdays = 0 ;
      double tax = 0.06;
      double fee = 0.70;
      double taxtotal = 0;         
      double subtotal = 0;
      double total= 0;
  
      String title = \"Madison Kennel & Grooming\";     // String Object for title
      String first_name,last_name,breed;
      String pit = \"Pit bull\";
      String dob = \"Doberman\";
      String rott = \"Rottweiler\";
  
  
      File board = new File(\"C:///boarding.txt\");
      Scanner inputFile = new Scanner(board);
  
      while (inputFile.hasNext())
   {
         first_name = inputFile.nextLine();
         last_name = inputFile.nextLine();
         breed = inputFile.nextLine();
         weight = inputFile.nextInt();
         numdays = inputFile.nextInt();
         inputFile.nextLine();
         inputFile.hasNext();

       
         System.out.println(first_name);
         System.out.println(last_name);
         System.out.println(breed);
         System.out.println(weight);
         System.out.println(numdays);
  
           if (breed == pit || breed == dob || breed == rott)
       {
         subtotal = subtotal + 20;
       }
       
             
             
                if (inputFile.hasNextLine())
       {
           inputFile.nextLine();
       }
       

      // Calculations for totals
  

  
      // Display output of totals
  
  
      subtotal = fee * weight * numdays;
      taxtotal = subtotal * tax;
      total = subtotal + taxtotal;
  

  
      System.out.println(\"\ \ \" + title + \"\ \" + \"-------------------------\" + \"\ \ \" +
                        \"Weight: \" + weight + \"\ \" + \"Boarding days: \" + numdays + \"\ \" +
                        \"Total boarding fee for \" + numdays + \" days (before taxes): $ \" +
                        subtotal + \"\ \" + \"Total amount of tax (6% tax rate): $ \" + taxtotal +
                        \"\ \" + \"Total boarding fee with tax: $ \" + total + \"\ \");
                 
                   double billtotal = 0;
                 
                      
                   for (int count = 0; count > total; count++)
                   {
                           billtotal = count;
                         
                    }
                  
                  
         System.out.println(billtotal);
       
       
          }
          }
}

Solution

Hi,

You mispaced if loop .

please find below corrected code

import java.io.File; // Importing respective packages
import java.io.FileNotFoundException;
import java.util.Scanner;
class file

{

public static void main(String[] args) throws FileNotFoundException
{
// Primitive variables for holding values for calulation.
  
int weight = 0;
int numdays = 0 ;
double tax = 0.06;
double fee = 0.70;
double taxtotal = 0;   
double subtotal = 0;
double total= 0;
  
String title = \"Madison Kennel & Grooming\"; // String Object for title
String first_name,last_name,breed;
String pit = \"Pit bull\";
String dob = \"Doberman\";
String rott = \"Rottweiler\";
  
  
File board = new File(\"C:///boarding.txt\");
Scanner inputFile = new Scanner(board);
  
while (inputFile.hasNext())
{
first_name = inputFile.nextLine();
last_name = inputFile.nextLine();
breed = inputFile.nextLine();
weight = inputFile.nextInt();
numdays = inputFile.nextInt();
inputFile.nextLine();
inputFile.hasNext();


System.out.println(first_name);
System.out.println(last_name);
System.out.println(breed);
System.out.println(weight);
System.out.println(numdays);

if (inputFile.hasNextLine())
{
inputFile.nextLine();
}

// Calculations for totals
  
  
// Display output of totals
  
  
subtotal = fee * weight * numdays;
  
   if (breed == pit || breed == dob || breed == rott)
{
subtotal = subtotal + 20;
}
     
taxtotal = subtotal * tax;
total = subtotal + taxtotal;
  
  
System.out.println(\"\ \ \" + title + \"\ \" + \"-------------------------\" + \"\ \ \" +
\"Weight: \" + weight + \"\ \" + \"Boarding days: \" + numdays + \"\ \" +
\"Total boarding fee for \" + numdays + \" days (before taxes): $ \" +
subtotal + \"\ \" + \"Total amount of tax (6% tax rate): $ \" + taxtotal +
\"\ \" + \"Total boarding fee with tax: $ \" + total + \"\ \");

double billtotal = 0;

  
for (int count = 0; count > total; count++)
{
billtotal = count;

}
  
  
System.out.println(billtotal);


}
}
}

cant figure out how to add $20 to variables if it equals one of the three: pit, rott, or dob also need total of all totals tried using \
cant figure out how to add $20 to variables if it equals one of the three: pit, rott, or dob also need total of all totals tried using \
cant figure out how to add $20 to variables if it equals one of the three: pit, rott, or dob also need total of all totals tried using \
cant figure out how to add $20 to variables if it equals one of the three: pit, rott, or dob also need total of all totals tried using \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site