EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
Expert Solution & Answer
Book Icon
Chapter 3, Problem 6PE

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...

Blurred answer
Students have asked these similar questions
Alert dont submit AI generated answer. in Java.
Create a calculator program. Get 2 numbers from the user. Create a method that adds the 2 numbers. Create a method that subtracts 1 number from the other. Create a method that multiplies the 2 numbers. Create a method that divides one number by another. It is important to check that you are not dividing by 0 here. You should be calling these methods from the main method and printing out the answers from the main method. Create a method that uses the modulus to return the remainder and the language is Java
Create a calculator program. Get 2 numbers from the user. Create a method that adds the 2 numbers Create a method that subtracts 1 number from the other Create a method that multiplies the 2 numbers Create a method that divides one number by another. It is important to check that you are not dividing by 0 here. You should be calling these methods from the main method and printing out the answers from the main method See sample output below: Please enter 2 integers Please enter 2 integers 12 You entered 12 & 6. You entered 0 & 0. 12 + 6 = 18 0 + 0 = 0 12 6 = 6 0 - 0 = 0 | 12 * 6 = 72 O * 0 = 0 12 / 6 = 2 Both numbers are 0 and cannot be divided. Returning 0 | Please enter 2 integers You entered 6 & 0. 6 + 0 = 6 6. 0 cannot be used to divide by so cannot do 6 /0 |0 / 6 = 0
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
    Text book image
    Microsoft Visual C#
    Computer Science
    ISBN:9781337102100
    Author:Joyce, Farrell.
    Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,