私のJavaの割り当てでは、起こっていたことを実行するプログラムを作成しましたが、私の教授からのフィードバックは次のようでした。このプログラムの主なタスクはメソッドを作成することでした。ただし、プログラム内にメソッドを作成していない。これにメソッドを追加するにはどうすればよいですか?java(jGrasp)でメソッドを追加
/* Daniel Martos
This program will make use of methods with parameters and return values,
the scanner class, string methods, and nested for Loops. It will ask the
user for their full name and the number of credits that they are taking.
It will then calculate the cost of their tuition and print out the user's
full name, and tuition cost.
*/
// Import the java.util package in order to work with the scanner class.
import java.util.*;
public class Martos3 {
// Create constants.
public static final double PER_CREDIT = 302.00;
public static void main (String [] args) {
// Create variables and objects.
int credTaken;
double cost;
String fullName;
// Create the console object to allow us to read information in from the keyboard.
Scanner console = new Scanner (System.in);
// Create executable code.
System.out.println ("Welcome to the Cal U Tuition Calculator Program");
System.out.print ("Please enter your full name: ");
fullName = console.nextLine();
System.out.print ("Please enter the number of credits taken: ");
credTaken = console.nextInt();
// Add a Nested for Loop to add the dashes
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 50; j++) {
System.out.print ("-");
}
System.out.println();
}
// Calculate the tuition cost.
cost = (credTaken * PER_CREDIT);
// Print out "Tuition calucation for" and the user's full name followed by a .
System.out.println ("Tuition calulation for " + fullName + ".");
// Print out "Credits Taken =" with the number of credits that the user enters.
System.out.println ("Credits Taken = " + credTaken);
// Print out "Tuition Cost = $" and the cost of tutition calculation.
System.out.println ("Tuition Cost = $" + cost);
}
}
あなたは情報を取得しようとしましたか、まさにどのような方法ですか? –
最初の方法は、学生の名前を聞くために使用する必要があります、2番目の方法は、学生が何クレジットを取っているか尋ねる必要があります、そして3番目は授業料を計算することです。私は私の教授に電子メールを送ってきました(連絡する方が好ましい方法)、私のクラスのディスカッション掲示板に投稿しました。私は必死だ、今夜が来るからだ。 –