Ok so i just started taking AP Computer Science at my high school and I really have no experience with java (just a little bit with python). So for our fist homework we had to try out a few codes and make some programs. I'm getting a " <identifier> expected error at "System.out.println("Enter firsr price ");". Please some help on how to fix it and dont laught at me for not being able to do such simple things, hey that's why I'm learning.

public class total
 
  {public static input in = new input();
    int A, B, C, D, F;
    
    System.out.println("Enter firsr price ");
    A = in.get.Int();
    
    System.out.print("Enter second price");
    B = in.get.Int();
    
    System.out.print("Enter third price");
    C = in.get.Int();
    
    D = (A+B+C)*.06
    F = A+B+C+D
    
    System.out.print("Sales tax is"(D));
    
    System.out.print("Total Cost is"(F));
    }
}

You code needs to be in a method. You currently have it in the body of the class itself.

Look at your other programs or examples and note how they declare a main() method and put the code in there.

You code needs to be in a method. You currently have it in the body of the class itself.

Look at your other programs or examples and note how they declare a main() method and put the code in there.

Ok so i fixed the first problem and a few others. Now, how do i get tu multiply the int by 0.06? here is the current code I have

import java.io.*;
public class total
 
  {public static input in = new input();
    
public static void main(String[] args) throws IOException
   {int A,B,C,D,G; 
    
    
            
            System.out.print("Enter firsr price ");
            A = in.getInt();
    
            System.out.print("Enter second price");
            B = in.getInt();
    
           System.out.print("Enter third price");
           C = in.getInt();
    
           D = (A + B + C)*0.06;
        
           
           G = A + B + C + D;
    
           System.out.print("Sales tax is");
           System.out.print(D);
    
           System.out.println("Total Cost is");
           System.out.print(G);
    }
}

You 'D' is supposed to get the total value of your A B and C right? Since 0.6 is a double value. . try to declare the D and G as double because you are passing double values now.

import java.io.*;
public class total
 
  {public static input in = new input();
    
public static void main(String[] args) throws IOException
   {
     int A,B,C;
     double D, G;
    
            System.out.print("Enter firsr price ");
            A = in.getInt();
    
            System.out.print("Enter second price");
            B = in.getInt();
    
           System.out.print("Enter third price");
           C = in.getInt();
    
           D = (A + B + C)*0.06;
        
           
           G = A + B + C + D;
    
           System.out.print("Sales tax is");
           System.out.print(D);
    
           System.out.println("Total Cost is");
           System.out.print(G);
    }
}

You 'D' is supposed to get the total value of your A B and C right? Since 0.6 is a double value. . try to declare the D and G as double because you are passing double values now.

import java.io.*;
public class total
 
  {public static input in = new input();
    
public static void main(String[] args) throws IOException
   {
     int A,B,C;
     double D, G;
    
            System.out.print("Enter firsr price ");
            A = in.getInt();
    
            System.out.print("Enter second price");
            B = in.getInt();
    
           System.out.print("Enter third price");
           C = in.getInt();
    
           D = (A + B + C)*0.06;
        
           
           G = A + B + C + D;
    
           System.out.print("Sales tax is");
           System.out.print(D);
    
           System.out.println("Total Cost is");
           System.out.print(G);
    }
}

Thank you so much I was trying double but I was trying the wrong way. Tt compiled perfectly now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.