Explanation of Solution
Program code:
BookStoreCredit.java
//import the required packages
import java.util.Scanner;
//define a class BookStoreCredit
public class BookStoreCredit
{
//define the main method
public static void main(String[] args)
{
//create object of Scanner
Scanner scanner = null;
//create a try...catch block
try
{
//scannner object
scanner = new Scanner(System.in);
// prompt to read name of student
System.out.print("Enter the Student name:");
//get the name to studentName
String studentName = scanner.next();
// prompt to read grade point average of student
System.out.print("Enter the Student grade point average:");
//get the input to gradePointAvg
double gradePointAvg = scanner.nextDouble();
// method call
display(studentName, gradePointAvg);
//catch the exception e
} catch (Exception e)
{
}
}
//define a method display()
public static void display(String studentName, double gradePointAvg)
{
//print the values
System.out.println("Student Name:" + studentName);
System.out.println("Grade point Average:" + gradePointAvg);
// compute the credit and display
System...
Trending nowThis is a popular solution!
Chapter 3 Solutions
EBK JAVA PROGRAMMING
- Create a method where a goblin will attack a zombie as long as the zombie has no health, otherwise the zombie is already dead. If the zombie has 0 or less health, the attack method should add 10 health to the zombie, bringing them closer to being alive so that they will be dead it should then return the zombies health. If the health of the zombie is positive the attack method should return "Zombie is alive, therefore it is not a zombie!". NOTE: This problem statement is extremely vague. This is to test how well you follow directions.arrow_forwardmaximum hours (inclusive). Make sure to cast the maximum range to an int before using it as parameter invoke the method to start the engine invoke the fly method and use as the input parameter the random number generated on the previous step invoke the method to land the plane and stop the engine invoke the addGas method. Invoke the calcGasNeededToFillTank () method to figure out the fuel needed to fill the tank and pass this value as input parameter to the addGas method.arrow_forwardCreate a program named PaintingEstimate whose Main() method prompts a user for length and width of a room in feet. Create a method that accepts the values and then computes the cost of painting the room, assuming the room is rectangular and has four full walls and 9-foot ceilings. The price of the job is $6 per square foot. Return the price to the Main() method, and display it. An example of the program is shown below: Enter length of the room in feet >> 30 Enter width of room in feet >> 16 Cost of job for 30 X 16 foot room is $4,968.00 In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US"))); using System; using static System.Console; using System.Globalization; class…arrow_forward
- A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program. Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. can you please write it in java.util.scanner form and can you make it so i can copy and past it thank you in advancearrow_forwardJavaarrow_forwardThe L&L Bank can handle up to 30 customers who have savings accounts. Design and implement a program that manages the accounts. Keep track of key information, and allow each customer to make deposits and withdrawals. Produce appropriate error messages for invalid transactions. Hint: You may want to baseyour accounts on the Account class from Chapter 5. Also provide a method to add 3 percent interest to all accounts whenever the method is invoked.arrow_forward
- Part 1 Motto Crispy Catering provides meals for parties and special events. Write a program that displays Crispy Catering's motto: "Crispy makes the food that makes it a party!" Display the motto surrounded by a border of asterisks. Put the code to display the motto in a method called, public void displayMotto () Run the program and save a screenshot of the output (save as screenshot 1)arrow_forwardWe will rewrite the Sales Bar Chart question to use method for printing out the bar chart. The part where the asterisks are printed out should be done with a method. Use this method for each bar. The original question statement is here: Write a program that asks the user to enter today’s sales for five stores. The program should display a bar chart comparing each store’s sales. Create each bar in the bar chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. Here is an example of the program’s output: Enter today's sales for store 1: 1000 [Enter] Enter today's sales for store 2: 1200 [Enter] Enter today's sales for store 3: 1800 [Enter] Enter today's sales for store 4: 800 [Enter] Enter today's sales for store 5: 1900 [Enter] SALES BAR CHART Store 1: ********** Store 2: ************ Store 3: ****************** Store 4: ******** Store 5: *******************arrow_forwardCreate a code that will run.arrow_forward
- Write a method that takes your name and your expected year of graduation and prints that information .Call this method from your main method, which takes user input and passes it to the method, described above. Name the program Lab27.java Add comments and upload it to the dropbox. Name: Miles Grear Expected year of graduation: 2024arrow_forwardWrite a main method, in which you should have an Arralylist of students, in which you should include every student. You should have a PhD student named Joe Smith. In addition, you should create an Undergraduate student object for each of your team members (setting their names). If you’re only one person doing the assignment, then you should just create one undergraduate object. For each undergraduate student, you should add add two courses (COIS 2240 and COIS 1020). Loop over the arraylist of students, print their names, if the student is an undergraduate student, print their courses.arrow_forwardWhen an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d = ½ gt2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. 5.3.1. Create a method: FallingDistance Parameters: t, object’s falling time (in seconds) t may or may not be an integer value! Return value: the distance, in meters, that the object has fallen during that time interval Calculations: Use Math.Pow() to calculated the square in the formula 5.3.2. Demonstrate the method by calling it from a loop that passes the values 1 through 20 as arguments, and displays each returned value. Sample output lines: . . . t = 5, d = 122.5 . . . t = 10, d = 490 . . . Your output should have lines for t=1, t=2, t=3, . . . t=20.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,