in java please A tip chart based 10 15 and 20 rate Bill rang

in java please

A tip chart based 10%, 15%, and 20% rate. Bill range: $1 to $100 in increments of fifty cents. Bill $1.00: 10% = $.10; 15% = $.15; 20% = $.20 ... Bill $100.00: 10% = $10.00; 15% = $15.00; 20% = $20.00

Code the problem using a main() method plus two additional methods. Use the names fvFor() and fvWhile() as your method names. Refer to the flow chart on void methods for guidance. In the main() method, call the fvFor() method and pass it two arguments: the lower and upper boundaries in the range; these values are specified for each problem. Pass both arguments to the method as numeric literals. Design and code the fvFor() method to receive the two parameters. Use the two parameters to govern a for loop within the method. You may need one or more additional local variables within the method. Inside the body of the for loop, perform whatever calculations are needed and display the output, one line for each iteration of the loop. When the for loop completes, return control to main(). Once you have the fvFor() method working, then modify main() so it calls fvWhile(). Again, pass the two values representing the range as numeric literals, and have the method receive the parameters and produce the output. If all goes well, main will call each method, in sequence, and you will get the same output twice: once by the for loop version of the method, and the other with the while loop version. As a final step on this problem, adapt main() so that it\'s a little more flexible. Allow the user to specify the lower and upper boundaries from which to produce the chart. Use main() to validate the end user\'s input to ensure that each value (lower and upper boundary) fall within the \"reasonable\" range as noted in the problem. For anything outside of that range, display an error message and end the program.

Solution

Program plan: As mentioned in the problem statement we need to create two methods fvFor() and fvWhile() having the parameters of lower and upper value.

Program:

import java.lang.*; //importing java libraries

class Tip //starting of the class

{ //main starts

public void static main(String arg[])

{

fvFor(1,100); //calling the fvFor method

fvWhile(1,100) //calling the fvWhile method

}

void fvFor(double lb,double ub) //definition of fvFor

{

for(double i=lb;i<=ub;i+=0.5)

{

System.out.println(\"10% tip value=\",i*0.1 );

System.out.println(\"15% tip value=\",i*0.15 );

System.out.println(\"20% tip value=\",i*0.2 );

}

}

void fvWhile(double lb,double ub)//definition of fvWhile

{

double i;

while(i<=ub)

{

System.out.println(\"10% tip value=\",i*0.1 );

System.out.println(\"15% tip value=\",i*0.15 );

System.out.println(\"20% tip value=\",i*0.2 );

i=i+0.5; //increments for every 50cents

}

}

}

in java please A tip chart based 10%, 15%, and 20% rate. Bill range: $1 to $100 in increments of fifty cents. Bill $1.00: 10% = $.10; 15% = $.15; 20% = $.20 ...
in java please A tip chart based 10%, 15%, and 20% rate. Bill range: $1 to $100 in increments of fifty cents. Bill $1.00: 10% = $.10; 15% = $.15; 20% = $.20 ...

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site