80.8k views
1 vote
Sara is writing a program to input her monthly phone bills and output the month name and amount for the month with maximum amount. She has defined an array to hold the month names. Complete the pseudocode program. [6] # Program to output maximum month's phone bill MonthName ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] # Define an array to hold the phone bills for each month

1 Answer

2 votes

Answer:

double [] phoneBills = new double[12];

Step-by-step explanation:

Since the question has requested that an array be difined to hold phone bill for each month. Above declares an array that will hold floating point number (double) and it has been created to hold 12 values representing the months January to December

Values can be added in the array as shown in the program below.

public class PhoneBill {

public static void main(String[] args) {

String [] MonthName = {"January", "February", "March", "April", "May", "June", "July", "August",

"September", "October", "November", "December"};

double [] phoneBills = new double[12];

phoneBills[0] = 4.5;

phoneBills[1] = 4.5;

phoneBills[2] = 5.5;

phoneBills[3] = 6.5;

phoneBills[4] = 3.5;

phoneBills[5] = 5.5;

phoneBills[6] = 6.5;

phoneBills[7] = 7.5;

phoneBills[8] = 8.5;

phoneBills[9] = 4.5;

phoneBills[10] = 3.5;

phoneBills[11] = 7.5;

System.out.println("Months and corresponding phone bill");

System.out.println(Arrays.toString(MonthName));

System.out.println(Arrays.toString(phoneBills));

}

}

The output of this program is attached:

Sara is writing a program to input her monthly phone bills and output the month name-example-1
User BBrill
by
4.2k points