r/javahelp • • Oct 01 '21

My first program

This is the first program ive ever tried to code and im running into a few compile errors i cant manage to resolve:

import java.io.*;
class Race_Track
{
   public static void main (String[] args)throws IOException
   {
   InputStreamReader inStream = new InputStreamReader (System.in);
   BufferedReader stdin = new BufferedReader (inStream);
   /* Setting Up Variables */ 
   int width_of_racetrack;
   int Bigger_Circle;
   int distance_from_track;
   int Smaller_circle;
   int Area_of_rt;
   int Total_Radius;
   int Circumference;
   int Cubic_foot_Big;
   int Cubic_foot_small;
   int volume_of_racetrack;
   int Tons_of_asphalt;
   /* Taking input and assigning them to variables */
   System.out.println("Enter the distance from the center to the racetrack (in metres): ");
   distance_from_track = Integer.parseInt(stdin.readline());
   System.out.println("Enter the width of the racetrack (in metres): ");
   width_of_racetrack = Integer.parseInt(stdin.readline());
   
   /* Calculating bigger circle and smaller circle, subtracting them
      To find the area of the racetrack */
   Total_Radius = width_of_racetrack + distance_from_track;
   Bigger_Circle = (2 * 3.14159 * Total_Radius * Total_Radius);
   Smaller_circle = (width_of_racetrack * width_of_racetrack * 2 * 3.14159);
   
   /* Finding the area of the racetrack and displaying */
   Area_of_rt = Bigger_Circle - Smaller_circle;
   System.out.println("The area to be paved is " + Area_of_rt + "Square Meters");
   
   /* Calculating the circumference of the racetrack and plus one because it wanted us to */
   Circumference = (2 * 3.14159 * (Total_Radius + 1));
   System.out.println("The amount of Fence needed is " + Circumference + "Meters");
   
   /* Calculating the volume for the big and small circles and subtracting for the 
      Volume of the racetrack */
   Cubic_foot_Big = ((4/3) * 3.14159 * (Total_Radius * Total_Radius * Total_Radius));
   Cubic_foot_small = ((4/3) * 3.14159 * (distance_from_track * distance_from_track * distance_from_track));
   volume_of_racetrack = Cubic_foot_Big - Cubic_foot_small;
   
   /* The weighted density of asphalt is around 145 pounds in per cubic foot on average.
      There are 2,000 pounds per tons. So multiplying by 145 to get it in pounds, and dividing by
      2000 to get it in pounds */
   Tons_of_asphalt = ((145 * volume_of_racetrack) / 2000);
   System.out.println("The amount of Asphalt needed is" + Tons_of_asphalt  + " in Tons");
   
   }
}
0 Upvotes

4 comments sorted by

View all comments

2

u/nutrecht Lead Software Engineer / EU / 20+ YXP Oct 01 '21

If you don't give us the errors we can't help you. You have to understand that we will generally not run your code for you.

Also you really should follow the standard naming conventions for Java, makes your code a lot easier to read.