To encourage good grades, Hermosa High School has decided to award each student a bookstore credit that is 10 times the student’s grade point average. In other words, a student with a 3.2 grade point average receives a $32 credit. Create a class that prompts a student for a name and grade point average, and then passes the values to a method that displays a descriptive message. The message uses the student’s name, echoes the grade point average, and computes and displays the credit. Save the application as BookstoreCredit.java.

Respuesta :

Answer:

// here is code in java.

import java.util.*;

// class definition

class BookstoreCredit

{

/* method that display descriptive message with name and grade point */

   public static void fun(String name,double grade)

   {

// multiply grade with 10

       grade=grade*10;

// print the message

       System.out.println(name+"\'s average grade is $"+grade);

   }

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read innput

       Scanner s=new Scanner(System.in);

        // variables

      String s_name;

      double grade;

      System.out.print("Please enter the name:");

      s_name=s.nextLine();

      System.out.print("Please enter the grade point:");

      grade=s.nextDouble();

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create variable s_name of string type and grade of double type.Read the student name and grade from user.call the fun() with these two parameter, where grade is multiplied by 10 and print the descriptive message which has student name and echoes the grade point average.

Output:

Please enter the name:john

Please enter the grade point:3.2

john's average grade is $32.0