Question: There are three program solutions of code using java and jGRASP listed below, provide Three changes if any or some recommendations per program solution as

There are three program solutions of code using java and jGRASP listed below,

provide Three changes if any or some recommendations per program solution as to how they could improve their program, and some things that were good in developing it. You also could add some knowledge and insight to enhance there program

give about 100- 200 word response per each

Solution 1

// This application gets a user's name and displays a greeting import java.util.Scanner; // This contains predefined utility classes public class FixDebugThree3 // Class name { // This is where the code starts for the class public static void main(String args[]) // This is the first method { // This is where the code starts String name; // This creates a string called "name" name = getName(); //fix1: getName is a method and was classified as a variable displayGreeting(name); // This displays the greeting with a name } // end of first method public static String getName() // this is the second method { // This is where the code starts String name; // name is the string name Scanner input = new Scanner(System.in); // Creates a object for the scanner class System.out.print("Enter name "); // This allows the user to enter a name name = input.nextLine(); // Fix2: this had nextInt // This return the next line return name; // This is used to return the name } // This is the end of the getName method public static void displayGreeting(String userName) // DisplayGreeting method definition { // This is where the code starts System.out.println("Hello, " + userName + "!"); // Error3: Replace name with userName.This prints out, "Hello,"Name"!" } // end of displayedGretting Method } // end of FixDebugThree3 class

Solution 2

public class FixDebugThree4//class header for FixDebugThree4 {//begin class FixDebugThree4

public static void main(String args[])//method header for psvmain {//begin psvmain // int myCredits = 13 int myCredits = 13;//missing semicolon; create variable myCredits with type int and value 13 // int yourCredits = 17 int yourCredits = 17;//missing semicolon; create variable yourCredits with type int and value 17 double rate = 75.84;//create variable rate as type double with the value 75.84 System.out.println("My tuition:");//Print the string My tuition: and go to next line tuitionBill(myCredits, rate);//call method tuitionBill with parameters myCredits and rate System.out.println("Your tuition:");//print the string Your tuition: and go to next line // tuitionBill(myCredits, rate); tuitionBill(yourCredits, rate);//wrong parameter being passed into tuitionBill(). Should have been yourCredits instead of myCredits; call method tuitionBill with parameters yourCredits and rate }//end psvmain // public static void tuitionBill(double r) public static void tuitionBill(int c, double r)//previous line missing the formal parameter for variable c in the method header for tuitionBill(). In the method call two actual parameters are beeing passed not one; method header for tuition bill with parameters c and r {//begin method tuitionBill System.out.println("Total due " + (r*c));//print the string "Total due" followed by the value of r times c and go to next line }//end tuitionBill }//end class FixDebugThree4

solution 3

// This program calculates tutition bills as credits times rate per credit hour public class DebugThree4 //This line is the class header { //This is a curly brace starts the code public static void main(String args[]) //This is the method to start the code { //this curly brace starts the main method int myCredits = 13; // This line needed a semicolon, 13 type is an int because it is a whole number, the variable is myCredits int yourCredits = 17; // This line needed a semicolon, 17 type is an int because it is a whole number, the variable is myCredits double rate = 75.84; // The amount of 75.84 is the double type because the value is in decimal form System.out.println("My tuition:"); // This line prints "My tuition" tuitionBill(myCredits, rate); //This line is a continuation from the line above System.out.println("Your tuition:"); //This line prints "Your tuition" tuitionBill(yourCredits, rate); //This was MyCredits, when it should be yourCredits } //This ends the method for tuitionBill public static void tuitionBill(int c, double r) // This line needed to include int c { //This curly brace opens the multiplication method for int c and double r System.out.println("Total due " + (r*c)); //This line is printed as "Total due" showing the value of r multiplied by c } //This curly bracket closes the multiplication method for tuitionBill } //This curly brace ends the code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!