Question

In: Computer Science

I entered in this code for my programming fundamentals class for this question To encourage good...

I entered in this code for my programming fundamentals class for this question

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

Create an application that prompts a student for a name and grade point average, and then passes the values to a method (computeDiscount) that displays a descriptive message. The message uses the student’s name, echoes the grade point average, and computes and displays the credit, as follows: John, your GPA is 3.4, so your credit is $34.0.

but it says it is only halfway done, what else do i need to add or get rid of?

import java.util.Scanner;

public class BookstoreCredit

{

public static void main(String[] args)

{

Scanner abc = new Scanner(System.in); //declaring scanner to take input from user

System.out.println("Enter your name ");

String name=abc.nextLine(); //taking input from user

System.out.println("Enter your GPA ");

Float gpa=abc.nextFloat(); //taking input from user

computeDiscount(name,gpa); //calling the function

}

private static void computeDiscount(String stdName,double gradeAverage)

{

Double gpa=gradeAverage; //copying the value of gradeAverage in gpa

gradeAverage = gradeAverage*10;

int i=(int)gradeAverage; //typecasting gradeAverage to int

System.out.println(" " + stdName +" ,your GPA is " + String.format("%.1f", gpa) +" ,so your credit is $"+ i );

}

}

Solutions

Expert Solution

import java.util.Scanner;

public class BookstoreCredit

{

        public static void main(String[] args)

        {

                Scanner abc = new Scanner(System.in); // declaring scanner to take input from user

                System.out.println("Enter your name ");

                String name = abc.nextLine(); // taking input from user

                System.out.println("Enter your GPA ");

                Float gpa = abc.nextFloat(); // taking input from user

                computeDiscount(name, gpa); // calling the function

        }

        private static void computeDiscount(String stdName, double gradeAverage){
                Double gpa = gradeAverage; // copying the value of gradeAverage in gpa
                gradeAverage = gradeAverage * 10;
                
                //System.out.println(" " + stdName +" ,your GPA is " + String.format("%.1f", gpa) +" ,so your credit is $"+ i );

                // we need to print it exactly what it is expecting
                System.out.println(stdName + ", your GPA is " + String.format("%.1f", gpa) + ", so your credit is $" + String.format("%.1f", gradeAverage)+".");

        }

}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Can you please give me a good question that I can present to my class on...
Can you please give me a good question that I can present to my class on Social Obedience? It has to be a question that the class can have a conversation about. Please give answer also.
I'm getting an error with my code on my EvenDemo class. I am supposed to have...
I'm getting an error with my code on my EvenDemo class. I am supposed to have two classes, Event and Event Demo. Below is my code.  What is a better way for me to write this? //******************************************************** // Event Class code //******************************************************** package java1; import java.util.Scanner; public class Event {    public final static double lowerPricePerGuest = 32.00;    public final static double higherPricePerGuest = 35.00;    public final static int cutOffValue = 50;    public boolean largeEvent;    private String...
The programming language that is being used here is JAVA, below I have my code that...
The programming language that is being used here is JAVA, below I have my code that is supposed to fulfill the TO-DO's of each segment. This code in particular has not passed 3 specific tests. Below the code, the tests that failed will be written in bold with what was expected and what was outputted. Please correct the mistakes that I seem to be making if you can. Thank you kindly. OverView: For this project, you will develop a game...
Why does my code print nothing in cout? I think my class functions are incorrect but...
Why does my code print nothing in cout? I think my class functions are incorrect but I don't see why. bigint.h: #include <string> #include <vector> class BigInt { private:    int m_Input, m_Temp;    std::string m_String = "";    std::vector<int> m_BigInt; public:    BigInt(std::string s)   // convert string to BigInt    {        m_Input = std::stoi(s);        while (m_Input != 0)        {            m_Temp = m_Input % 10;            m_BigInt.push_back(m_Temp);       ...
I have the following code for my java class assignment but i am having an issue...
I have the following code for my java class assignment but i am having an issue with this error i keep getting. On the following lines: return new Circle(color, radius); return new Rectangle(color, length, width); I am getting the following error for each line: "non-static variable this cannot be referenced from a static context" Here is the code I have: /* * ShapeDemo - simple inheritance hierarchy and dynamic binding. * * The Shape class must be compiled before the...
hi i do not know what is wrong with my python code. this is the class:...
hi i do not know what is wrong with my python code. this is the class: class Cuboid: def __init__(self, width, length, height, colour): self.__width = width self.__length = length self.__height = height self.__colour = colour self.surface_area = (2 * (width * length) + 2 * (width * height) + 2 * (length * height)) self.volume = height * length * width def get_width(self): return self.__width def get_length(self): return self.__length def get_height(self): return self.__height def get_colour(self): return self.__colour def set_width(self,...
I have this question in my nursing class I just need someone to answer it for...
I have this question in my nursing class I just need someone to answer it for me Reflect on an occasion where you experienced ineffective leadership (doesn't have to be in the hospital/healthcare). What behaviors did they display? What factors may have influenced their leadership style?
This is a question for my biochemistry class. I have copied and pasted it below. This...
This is a question for my biochemistry class. I have copied and pasted it below. This is all that was given to me. Diagram the flow of genetic material in a cell.
I have a question about C++ programming Language class. I am confused with these terms and...
I have a question about C++ programming Language class. I am confused with these terms and what they are for. 1. Unix 2. Terminal 3. Git 4. CLOC 5. Linux Please explain each words and what's their jobs for C++. Also, if you know some good sources/websites, could you please provide me a link where I can learn how to use Unix, Terminal, Git, etc.
I need a good topic for the Quality Improvement Report, it's for my operational management class....
I need a good topic for the Quality Improvement Report, it's for my operational management class. Any suggestions... You will complete a Quality Improvement Report after identifying a deficiency in the workplace or home environment and developing a plan to address the issue(s). The self-selected location and short overview of the deficiency will be submitted to the instructor for approval in Week 2. Using various components of the Total Quality Management (TQM) Philosophy, students will create a plan that serves...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT