Alright, so I received an assignment from my teacher to make a program that uses if and for loops to allow the reader to pick to calculate the circumference and area of a circle. The teacher said it needs to list the values with the radius increasing in a for loop from 1 to 20. I have only gotten so far as to create the circle with one radius because the looping is not working (supposedly because the radius has to be plugged into an equation). I have tried to switch some code around and add more, however none of my fixes seem to make much difference. I have hit a brick wall so could somebody please help me?
// *****: This is program lists 20 circumfrence values of a circle and 20 area values of a circle. Comments are in green text. // Syntax error = typing error - Does not compile // Logical error flaw is your reasoning they do compile. // Runtime error does compile but the program crashes when it runs. (Divide by zero) // Import some code import TerminalIO.KeyboardReader; //This is a piece of code to read characters from the keyboard. import java.text.DecimalFormat; //This piece of code is imported so the twoDecimal value will work. class Circle {//This class name matches the file name. public static void main(String args[]) { //Must have this line in all programs. // decimals = double KeyboardReader reader = new KeyboardReader();// Declares an object called reader that takes the form of Keyboard reader. DecimalFormat twoDecimal = new DecimalFormat("0.00"); //Declares how many decimals that is created. int i; double circumference, area, pi, circletype; System.out.println("Enter the value of Pi."); pi = reader.readDouble(); //Finds pi System.out.println("To find the circumfrence of a circle type 1. To find the area of a circle type 2."); circletype = reader.readDouble(); //Reader decides to find the area or the circumfrence if(circletype == 1){ for (i=1; i<=20; i=i+1); //Loop circumference = (2 * pi * i); System.out.println("The circumference of a circle with a radius from 1 to 20 is, "+ circumference); //Loop of 20 different values in increasing order } } }