Q8: Put the code in the correct order to create a program that will generate a value 0 to 1500 inclusive, assign a value to double variable cost depending on the value of integer variable distance as shown in the table above, and then print both values.
Q9: Put the code in the correct order to create a program that will generate an integer between 1 and 7, print the value, and display the name of the weekday where 1 is Sunday and 7 is Saturday.
impot java.util.*;
public class main {
public static void main(String[] args) {
---
Random r = new Random();
int x = 1 + r.nextInt(7);
String result = "";
System.out.println(x);
---
switch (x) {
---
case 1: result = "Sunday"; break;
case 2: result = "Monday"; break;
case 3: result = "Tuesday"; break;
case 4: result = "Wednesday"; break;
case 5: result = "Thursday"; break;
case 6: result = "Friday"; break;
case 7: result = "Saturday"; break;
---
}
---
System.out.println(result);
---
}
}
Q10: Put the code in the correct order to create a program that will generate an integer between 65 and 122 inclusive and then convert that code to a character through a cast. The program should then print the character value and print “Vowel” or “Consonant” depending on the character value. If the character is not a letter (between a and z or A and Z), then an error message should be printed. Vowels are considered to be {a, e, i, o, u}.