英文:
I need my code to display the users name, their GPA, and then a credit which is their GPA times 10
问题
我需要我的代码显示用户的姓名,他们的GPA,然后是一个学分,该学分是他们的GPA乘以10。下面是
英文:
I need my code to display the users name, their GPA, and then a credit which is their GPA times 10. The code below is what I have so far but every time I run the program the output is just, "EEEEEEEEEE EEEEEE....". Can you guys please tell me what I can do to fix this? All help is appreciated and thanks in advance!
import java.util.Scanner;
public class BookstoreCredit {
public static void main (String args[])
{
String name;
double gpa;
Scanner inputDevice = new Scanner(System.in);
System.out.print ("Please enter your name >>> ");
name = inputDevice.nextLine();
System.out.print ("Please enter your grade point average >>> ");
gpa = inputDevice.nextDouble();
System.out.print (name);
System.out.print (", your GPA is ");
System.out.print (gpa);
System.out.print (", so your credit is $");
}
public static void computeDiscount(String name, double gpa)
{
double credit;
credit = gpa * 10.0;
}
}
答案1
得分: 0
你是不是在说这样的内容?
import java.util.Scanner;
public class BookstoreCredit {
public static void main(String args[]) {
String name;
double gpa;
Scanner inputDevice = new Scanner(System.in);
System.out.print("Please enter your name >>> ");
name = inputDevice.nextLine();
System.out.print("Please enter your grade point average >>> ");
gpa = inputDevice.nextDouble();
System.out.print(name);
System.out.print(", your GPA is ");
System.out.print(gpa);
System.out.print(", so your credit is " + computeDiscount(gpa));
}
public static double computeDiscount(double gpa) {
double credit;
credit = gpa * 10.0;
return credit;
}
}
英文:
Are you talking something like this?:
import java.util.Scanner;
public class BookstoreCredit {
public static void main(String args[]) {
String name;
double gpa;
Scanner inputDevice = new Scanner(System.in);
System.out.print("Please enter your name >>> ");
name = inputDevice.nextLine();
System.out.print("Please enter your grade point average >>> ");
gpa = inputDevice.nextDouble();
System.out.print(name);
System.out.print(", your GPA is ");
System.out.print(gpa);
System.out.print(", so your credit is " + computeDiscount(gpa));
}
public static double computeDiscount(double gpa) {
double credit;
credit = gpa * 10.0;
return credit;
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论