64.6k views
3 votes
Write an algorithm/flowchart using raptor that has the following three sub-flowcharts/subprocedures

a) readData
b) maxincome
c) avgIncome
a) The provided income.txt file saves the income (in dollar) of twelve months starting from January to December. Design the readData sub-flowchart to read the provided text file income.txt. The readData sub-flowchart creates two arrays called months and income. The month array saves the month names and the income array saves the income of that month.
b) The max Income sub-flowchart outputs the month name that has the maximum income.
c) The avgIncome sub-flowchart outputs the average income per year.

User Harumi
by
8.2k points

2 Answers

3 votes

Final answer:

The question requires creating sub-flowcharts in Raptor for reading data from a text file, finding the maximum income, and calculating the average income, involving the initialization of 'months' and 'income' arrays and processing based on those arrays.

Step-by-step explanation:

The designing an algorithm or flowchart using Raptor to handle the tasks of reading data from a text file, determining the maximum income from the read data, and calculating average income. Below are descriptions of the sub-flowcharts: readData: This sub-flowchart reads the income.txt file and initializes two arrays named months and income. The months array holds the names of the months January to December, and the income array stores the corresponding income values for each month.

max Income: This sub-flowchart scans the income array to find the maximum income and outputs the name of the corresponding month from the months array that has this maximum income. avg Income: The third sub-flowchart calculates the average income over the twelve-month period by summing all the income values from the income array and dividing by 12, then outputs the result.

User Martin Owen
by
7.7k points
3 votes

Final answer:

To design an algorithm/flowchart using Raptor with three sub-flowcharts/subprocedures: readData, maxincome, and avgIncome.

Step-by-step explanation:

To design an algorithm/flowchart using Raptor with three sub-flowcharts/subprocedures: readData, maxincome, and avgIncome, you can follow the following steps:

readData: Create two arrays called 'months' and 'income' to read the provided text file 'income.txt' which saves the income of twelve months. 'months' array saves the month names, and 'income' array saves the income of each month.

maxIncome: Calculate the month with the maximum income by iterating through the 'income' array and keeping track of the maximum income value and its corresponding month name.

avgIncome: Calculate the average income per year by summing up all the income values in the 'income' array and dividing it by the total number of months (which is 12 in this case).

The algorithm for reading data from the "income.txt" file using RAPTOR involves opening the file, initializing arrays for months and income, and populating them with corresponding data. The maxIncome sub-flowchart identifies the month with the highest income, while the avgIncome sub-flowchart calculates the average income per year.

Utilizing a while loop, the readData sub-flowchart iterates through the file, extracting month names and income values. These sub-flowcharts collectively facilitate effective handling and analysis of monthly income data, supporting tasks such as identifying the month with the highest income and computing the average annual income.

User Sherika
by
7.5k points