Question: Write java script for the following questionnaire from Zybooks. Note: Since all the programs run on Zybooks compiler use tha name for each program as
Write java script for the following questionnaire from Zybooks.
Note: Since all the programs run on Zybooks compiler use tha name for each program as Main.
Ex: public class Main {
1. Create a class called "Student". Declare two private member fields for a student name (String) and GPA (double). Provide a constructor, get methods and set methods as shown below.
public Student() - set name to "Louie" and GPA to 1.0
public void setName(String n) - set the name
public String getName() - return the name
public void setGPA(double g) - set the GPA
public double getGPA() - return the GPA
2. Write a main method to prompt the user for an integer that represents the number of large pizzas to be ordered ($9.99 each). Calculate and display the sub-total before sales tax. Calculate and display the total due by applying a sales tax of 6%. Use the NumberFormat to display currency.
Sample Output How many pizzas? 3 Sub Total: $29.97 Total Due: $31.77
3. Write a main method to prompt the user for two integers. Use the Random class to generate three numbers all within the range of low to high (inclusive).
Sample Output
Enter low: 15
Enter high: 20
Random values: 20 19 15
4. Write a main method to prompt the user for three numbers (doubles) that represent the side lengths of a triangle. Calculate the area of the triangle using Math.sqrt(). Print the area to three decimal places using DecimalFormat.
s = half the triangle's perimeter
area = the square root of s(s-a)(s-b)(s-c)
Sample Output
Enter Side A: 3
Enter Side B: 3
Enter Side C: 1
The area of the triangle is: 1.479
5. Write a main method that prompts the user for a first name, a last name and a four-digit integer (use nextInt()) on separate lines. Generate a login name that includes the first five letters of the last name, followed by the first letter of the first name and then the last two digits of the number (use the % operator).
Enter first name: Jeremy
Enter last name: Johnson
Enter 4-digts: 6789
Your login name: JohnsJ89
6. Write a main method that prompts the user for two doubles that are the radius and height of a cylinder. Calculate the volume and the area, as given by following two equations, using Math.pow() and Math.PI and print the results. Print the results to one decimal place using DecimalFormat.
Volume = r2h
Area = 2rh
Sample Output
Enter Radius: 5.2
Enter Height: 8.1
Volume: 688.1 cubic inches.
Surface Area: 264.6 square inches.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
