Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.util.Scanner; public class Project2 { public static void main(String

ID: 3672632 • Letter: I

Question

import java.util.Scanner; public class Project2 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); System.out.println("Enter first name"); //entering the first name String first=sc.next(); //entering the last name System.out.println("Enter Last name"); String last=sc.next(); //entering the radius System.out.println("Enter Radius"); float rad=sc.nextFloat(); //Enter Height System.out.println("Enter height"); float height=sc.nextFloat(); //entering binary number System.out.println("Enter binary number"); String binaryString =sc.next(); //converting given binary to decimal int bd=Integer.parseInt(binaryString,2); // generating random radious between 1 and given binary num double randrad=(Math.random())*bd; //generating random height between 1 and 10 double randht=(Math.random())*10; //Caluclating volume for both cylinders double vol1=3.14*rad*rad*height; double vol2=3.14*randrad*randrad*randht;    System.out.println("Hello "+first+" "+last); System.out.println("volume of Cylinder with radious "+rad+" height "+height+"is"+vol1); System.out.println("Random Cylinder volume with radious "+randrad+" height "+randht+"is"+vol2); System.out.println("the binary value of"+binaryString+" is "+bd);    } }

this is what i have wrtten and i get these errors in my mac through textwrangler:

Project2.java:31: error: illegal character: 'u00a0'

  

^

Project2.java:31: error: illegal character: 'u00a0'

  

^

Project2.java:32: error: ';' expected

System.out.println("Hello "+first+" "+last);

^

Project2.java:36: error: illegal character: 'u00a0'

  

^

Project2.java:36: error: illegal character: 'u00a0'

  

^

Project2.java:36: error: ';' expected

  

^

Project2.java:38: error: reached end of file while parsing

}

^

7 errors

Explanation / Answer

Hi, I have freshly typed your program.

You can use it now.

import java.util.Scanner;

class Project2 {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter first name");
       // entering the first name
       String first = sc.next();
       // entering the last name
       System.out.println("Enter Last name");
       String last = sc.next();
       // entering the radius
       System.out.println("Enter Radius");
       float rad = sc.nextFloat();
       // Enter Height
      
       System.out.println("Enter height");
       float height = sc.nextFloat();
       // entering binary number
       System.out.println("Enter binary number");
       String binaryString = sc.next();
       // converting given binary to decimal
       int bd = Integer.parseInt(binaryString, 2);
       // generating random radious between 1 and given binary num
       double randrad = (Math.random()) * bd;
       // generating random height between 1 and 10
       double randht = (Math.random()) * 10;
       // Caluclating volume for both cylinders
       double vol1 = 3.14 * rad * rad * height;
       double vol2 = 3.14 * randrad * randrad * randht;
       System.out.println("Hello " + first + " " + last);
       System.out.println("volume of Cylinder with radious " + rad
               + " height " + height + "is" + vol1);
       System.out.println("Random Cylinder volume with radious " + randrad
               + " height " + randht + "is" + vol2);
       System.out.println("the binary value of" + binaryString + " is " + bd);
   }
}

/*

Output:

Enter first name
Alex
Enter Last name
Bob
Enter Radius
10
Enter height
12
Enter binary number
001100
Hello Alex Bob
volume of Cylinder with radious 10.0 height 12.0is3768.0
Random Cylinder volume with radious 4.522727598719463 height 2.8435560340752897is182.6384872103949
the binary value of001100 is 12

*/