Write a Java program

Feb 3rd, 2014
Anonymous
Category:
Calculus
Price: $10 USD

Question description

I have a Java program that just needs to be tweaked to make simpler, basically just to redo the code without the loop. 

here's the code 

import java.util.*;

public class PossibleCircle 

{

  public static void main(String[] args)  

  {

    Scanner input = new Scanner(System.in);

   

    int runningTotal = 0;

    int currentInput; 

    int[] radius_inch = new int[5];

int total=0;

double area;

double circumference;

double radius_cm;

double average;

    final double IN_TO_CM = 2.54;

System.out.println("Enter radius for each circle in inches");

for(int i=0;i<5;i++)

{

System.out.print("Enter radius of circle "+ (i+1) + ":" );

radius_inch[i] = input.nextInt();

total = total + radius_inch[i];

}

        System.out.print("Radius (in.)  ");

        System.out.print("Radius (cm.)  ");

        System.out.print("Area (sq. cm.)  ");

        System.out.println("Cirumference (sq. cm.)");

System.out.println("__________________________________________________________________________________________________");

for(int i=0;i<5;i++)

           

{

radius_cm = IN_TO_CM * radius_inch[i];

area =  Math.PI * radius_cm * radius_cm;

circumference = 2 * Math.PI * radius_cm;

System.out.printf("%10d\t\t%10.1f\t\t%10.1f\t\t%10.1f\n",radius_inch[i],radius_cm,(double)Math.round(area*10)/10, (double)Math.round(circumference*10)/10);

}

average = total/5;

double d = (double)Math.round(average*10)/10;

    System.out.println("The average of all the radii is:" + d +" inches.");

  }

}


Tutor Answer

(Top Tutor) simba
School: Rice University

Studypool has helped 1,244,100 students

Review from student
Anonymous
" Thanks, good work "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1827 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors