Programming Homework Help

Java Script Rutgers Debug Programming Exercise

 

db5-1. Fix the errors on the attached debug exercise 5-1. There could be syntax and logic errors. You want to calculate what you should leave for a tip in a separate user-defined method called calctip. Pay particular attention to arguments to the calctip method and the return from the calctip method back to main. Save as db51.java, attach your completed file and submit. This is the code that needs to be debugged:

/* d51.java

This program calculates a waitperson's tip
*/
public class d51
{
	public static void main(String[] args)
	{
	  double mycheck = 29.95, yourcheck = 39.95, mytip, yourtip;
	  System.out.println("Tips are");
	  calctip(double mycheck);
	  System.out.printf("My tip should be at least %.2fn", tip);
	  calctip(double yourcheck);
	  System.out.printf("Your tip should be at least %.2fn", tip);
	}

	public static void calctip()
	{
	  double tip;
	  tip = bill * .15;
	  return tip;
	}
}