95.3k 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.


# 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

User John Zhao
by
6.9k points

2 Answers

6 votes

Final answer:

Sara can write a pseudocode with arrays MonthName and PhoneBill to find the month with the highest phone bill by comparing values using a loop and output the month with maximum expense.

Step-by-step explanation:

Sara wants to write a program to find the month with the highest phone bill. To do this, she needs to track both the monthly bills and the corresponding month names. Below is a pseudocode program that accomplishes this task:

Pseudocode Program

  • Initialize MonthName array with months January to December.
  • Define a PhoneBill array to hold the monthly phone bills.
  • Initialize a variable maxAmount to hold the highest bill amount and another variable maxMonth to hold the month of the highest bill.
  • Use a loop to iterate through the PhoneBill array.
  • Within the loop, check if the current month's bill is greater than maxAmount.
  • If true, update maxAmount with the current bill amount and maxMonth with the corresponding month name.
  • After the loop, output the month and amount for the month with the maximum bill.

By following this pseudocode, Sara will be able to input her monthly phone bills and seamlessly identify the month with the maximum expense.

User Dsynkd
by
6.3k points
4 votes

Answer:

# include <conio.h>

#include <iostream.h>

using namespace std;

main()

{

int billamount[12];

char monthname["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];

for (int month = 1 ; month<=12; month++)

{

cout<<"Enter the amount of bill for the month"<<month;

cin>>billamount[month];

}

for (i=0; i<= 12; i++)

{

if (billamount[0]<billamount[i])

billamount[0]=billamount[i];

monthname[0]=monthname[i];

}

cout<<"Maximum months phone bill"<<monthname[0]<<"="<<billamount[0]

getch();

}

User Keshlam
by
6.4k points