Financial Records Create a program to store weekly expenses and revenues over a
ID: 3808926 • Letter: F
Question
Financial Records
Create a program to store weekly expenses and revenues over a p
eriod of time. The program should
store the expenses and revenues in two global array variabl
es. Values stored in the array at index
k
represent the total revenues/expenses recorded during the
k
th
week. Assume that the maximum number
of weeks tracked is 250.
Add the following functions to your program:
-
A function that finds the total of all expenses incurred
since week
t
for a given t.
-
A function that records the total expenses and revenues for
the next unrecorded week. It must
check if there is still space in the array.
-
A function that prints the number of weeks recorded
-
A function that prints all revenues and expenses recorded
-
A function that returns a pointer to the largest revenue rec
orded
Organize the program so the function prototypes are presented
first, and the definitions after the main
function. Your program should keep asking the user to select
one of the following options and execute
the corresponding function based on the user choice:
(A)
computed the total of all expenses,
(B)
add a new expense/revenue ,
(C)
print the number of weeks recorded,
(D)
print all revenues and expenses recorded,
(E)
print the largest reven
Explanation / Answer
Financial Records
#include<stdio.h>
int revenue[250];
int expense[250];
int n;
void printweek(int t, int reve[], int exp[])
void main()
{
n=3; int k,n1;
revenue[]={100,150,250};
expense[]={80,120,240};
printf(" Select the options from the list:");
printf(" 1.Print all recorded revenues and Expenses");
printf(" 2.total of all expenses incurred since nth week");
printf(" 3.records the total expenses and revenues for the next unrecorded week");
printf(" 4.prints the number of weeks recorded:");
printf(" 5.print the largest revenue");
do
{
switch(c){
case 1:
printall(n,revenue,expense);
break;
case 2:
print(" Enter the week :");
scanf("%d",&n1);
printexp(n1,n,expense);
break;
case 3:
add(n,revenue,expense);
break;
case 4:
printf(" Total number of records: %d", n);
break;
case 5:
large(n,revenue[]);
break;
default:
exit;
} while(c<6);
}
printweek(k,revenue,expense);
}
void printall(int t, int reve[],int exp[])
{
printf(" WEEK REVENUE EXPENSE");
for(int i=0;i<t;i++)
printf(" %d %d %d",t,reve[t],exp[t]);
}
void printexp(int t,int t1,int exp[])
{
int tot=0;
printf(" Total Expenses");
for(int i=t-1;i<t1+1;i++)
tot=tot+exp[i];
print("%d",tot);
}
void add(int t, int reve[],int exp[])
{
if(t<250)
{
printf(" Enter the revenue and expense for next week");
scanf("%d%d",&reve[++t],&exp[++t]);
}
else
printf("Out of Array");
t++;
}
void large(int t, int reve[])
{
int lar = reve[0];
for (int i = 1; i < t; i++)
{
if (lar < reve[i])
lar = reve[i];
}
print(" The largets revenue : week%d %d",i,reve[i]);
}
void printweek(int t, int reve[], int exp[])
{
printf(" the revenues and expenses of week %d :",t);
printf(" REVENUE EXPENSE");
printf(" %d %d",reve[t],exp[t]);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.