This is the debugs for chapter 3 of Java programming. There are two that need fi
ID: 3547782 • Letter: T
Question
This is the debugs for chapter 3 of Java programming. There are two that need fixed and that is why I am offering such high points. As soon as I test and run the fixed debugs I will award the points right away.
1. // This application gets a user's name and displays a greeting
import java.util.Scanner;
public class DebugThree3
{
public static void main(String args[])
{
String name;
getName();
displayGreeting(name);
}
public static String getName()
{
String name;
Scanner input = new Scanner(System.in);
System.out.print("Enter name ");
name = input.nextInt();
return name;
}
public static void displayGreeting()
{
System.out.println("Hello, " + name + "!");
}
}
2. // This program calculates tutition bills as credits times rate per credit hour
public class DebugThree4
{
public static void main(String args[])
{
int myCredits = 13
int yourCredits = 17
double rate = 75.84;
System.out.println("My tuition:");
tuitionBill(myCredits, rate);
System.out.println("Your tuition:");
tuitionBill(myCredits, rate);
}
public static void tuitionBill(double r)
{
System.out.println("Total due " + (r*c));
}
}
Explanation / Answer
1)
import java.util.Scanner;
public class DebugThree3{
public static void main(String args[]) {
String name;
name= getName();
displayGreeting(name);
}
public static String getName() {
String name;
Scanner input = new Scanner(System.in);
System.out.print("Enter name ");
name = input.nextLine();
return name;
}
public static void displayGreeting(String name) {
System.out.println("Hello, " + name + "!");
}
}
2)
public class DebugThree4{
public static void main(String args[]) {
int myCredits = 13;
int yourCredits = 17;
double rate = 75.84;
System.out.println("My tuition:");
tuitionBill(myCredits, rate);
System.out.println("Your tuition:");
tuitionBill(yourCredits, rate);
}
public static void tuitionBill(int c,double r) {
System.out.println("Total due " + (r * c));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.