Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Unit 3 Skill Practice
- ***multiple choice questions 6,7,8,13 have already been done before***
- 17. 5
- 18. 2.0
- 19. 3.141592653589793
- 20. 6
- 21. 4
- 22. 8
- 23. 8.0
- 28. System.out.print("\"Welcome " + "to " + "Java " + "Illuminated\"");
- 29. int i = Math.min(3,5);
- System.out.print(i);
- 30. double d = 5.0;
- System.out.print(Math.sqrt(d));
- 31.
- import java.util.*;
- public class scanner
- {
- public static void main (String [] args)
- {
- Scanner console = new Scanner(System.in);
- System.out.println("Type in a value.");
- int x = console.nextInt();
- System.out.println("Type in another value.");
- int y = console.nextInt();
- System.out.print("The minimum is " + Math.min(x,y));
- }
- }
- 32.
- import java.util.*;
- public class 3scanner
- {
- public static void main (String [] args)
- {
- Scanner console = new Scanner (System.in);
- System.out.println("Type in a value");
- int x = console.nextInt();
- System.out.println("Type in another value.");
- int y = console.nextInt();
- System.out.println("Type in a third value.");
- int x = console.nextInt();
- System.out.print("The maximum of the three values is " + Math.max(x,y,z));
- }
- }
- 34.
- import java.util.*;
- public class doubleScanner
- {
- public static void main (String [] args)
- {
- Scanner console = new Scanner (System.in);
- System.out.println("Type in a value.");
- double x = console.nextDouble();
- System.out.println("The square of the value is " + x*x);
- }
- }
- 40. data type short cannot have a decimal point; should be either float or double
- 41. int should be double
- 42. should be Math.PI
- 46. math should be capitalized, should be Math.sqrt(6);
- 47. shouldn't be parentheses after Math.PI, take out parentheses
- 48. e should be capitalized, should be Math.E;
- 53.
- import java.util.*;
- public class question53
- {
- int rand;
- int x;
- int y;
- public static void randomNumber() //this is the random method
- {
- Random rand = new Random();
- int x = rand.nextInt(101);
- System.out.println("One of the 2 random numbers is " + x);
- Random rand2 = new Random();
- int y = rand.nextInt(101);
- System.out.println("The other random number is " + y);
- System.out.print("The minimum of the two numbers is " + Math.min(x,y));
- }
- }
- 54.
- import java.util.*;
- public class question54
- {
- public static void scannerMethod() //this is the scanner
- {
- Scanner console = new Scanner(System.in);
- System.out.println("Type in any number.");
- double x = console.nextInt();
- System.out.println("The cube of the number is " + x*x*x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment