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.
This is my last assignment in a programming class I had to take as a prerequisite...
This is my last assignment in a programming class I had to take as a prerequisite for a database course (seems odd). The instructor has been awful and I haven't learned much of anything. I use VBA at work and just can't follow C++. I'm stuck on this assignment and have no idea what I'm doing. I'm a database guy at work, I'm not a programmer. Please help. In C++, a program that performs the following tasks: 1.      Design a Book...
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 need to translate my java code into C code. import java.util.Scanner; class CS_Lab3 { public...
I need to translate my java code into C code. import java.util.Scanner; class CS_Lab3 { public static void main( String args[] ) { Scanner input = new Scanner( System.in ); // create array to hold user input int nums[] = new int[10]; int i = 0, truthCount = 0; char result = 'F', result2 = 'F'; // ask user to enter integers System.out.print("Please Enter 10 Different integers: "); // gather input into array for ( i = 0; i <...
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?
My question is on this program I have difficulty i marked by ??? public class SortedSet...
My question is on this program I have difficulty i marked by ??? public class SortedSet { private Player[] players; private int count; public SortedSet() { this.players = new Player[10]; } /** * Adds the given player to the set in sorted order. Does not add * the player if the case-insensitive name already exists in the set. * Calls growArray() if the addition of the player will exceed the size * of the current array. Uses an insertion sort...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT