i wrote this code:
import java.text.DecimalFormat; import java.util.Scanner; public class salary { public static void main(String[] args) { //declare variables int years = 1, maxValue; double salary = 500; double averageSalary = 0; double totalPay = 0; //Create decimal formatter DecimalFormat formatter = new DecimalFormat("$0,000.00"); //create a scanner Scanner keyboard = new Scanner(System.in); //Receive the number of years to work System.out.print("How many years will you work? "); maxValue = keyboard.nextInt(); //Determine is years are correct if (years < 1 || years > 60) { System.out.println("Years must be between 1 and 60"); } else { //Return Salary table System.out.println("Year \t\tSalary Earned"); System.out.println("--------------------------"); for (years = 1; years <= maxValue; years++) { System.out.println(years + "\t\t" + (formatter.format(salary *= 2))); totalPay += salary; averageSalary = totalPay / years; } //display totals System.out.println("\nTotal pay: " + (formatter.format(totalPay))); System.out.println("Average salary: " + (formatter.format(averageSalary))); } } }
this code runs correcty as is, but how do i change it to create instead of a table with a salary a table with ***
for example
current out put would be :
desired output would be----jGRASP exec: java salary
How many years will you work? 4
Year Salary Earned
--------------------------
1 $1,000.00
2 $2,000.00
3 $4,000.00
4 $8,000.00
Total pay: $15,000.00
Average salary: $3,750.00
----jGRASP: operation complete.
----jGRASP exec: java salary
How many years will you work? 4
Year Salary Earned
--------------------------
1 *
2 **
3 ****
4 ********
Total pay: $15,000.00
Average salary: $3,750.00
----jGRASP: operation complete.