Question: I am trying to take a C programming program and add functions to it , this is the original working program / * THIS PROGRAM
I am trying to take a C programming program and add functions to it this is the original working program
THIS PROGRAM DOES NOT USE FUNCTIONS; THE TASK IS TO REWRITE IT USING FUNCTIONS
Markupc by CIS
Input: Keyboard
Output: Screen
This program calculates markup price of an inventory item. Items are marked up by
An item count and grand total of the marked up values is accumulated and printed at the end
of the program. This program will include separate functions for: heading, inputs,
processing and outputs after it is restructured using functions.
#include
int main void
Declaration
int itemNo itemCount;
float costf markedupf grandTotal f;
char again Y;
Heading
printfMarkup Calculator by You
;
Begin Loop
while again Y again y
Input Section
do
Validate entry
printf
Enter Item Number ;
scanfd &itemNo;
if itemNo itemNo
printfItem Number not accepted, enter an Item Number
;
while itemNo itemNo ;
printfEnter the cost of the inventory item ;
scanff &cost;
Processing Section
markedup cost f; calculate markup
Accumulate count, total and loop
itemCount;
grandTotal markedup;
Output Section
printf
The unit cost for item d is f
itemNo, cost;
printfThe marked up sales amount is f
markedup;
Prompt user to determine if loop should continue
printfEnter another item? Enter Y or N ;
scanf c &again; note the space in the conversion specifier
End Loop
Print count, final total
printf
Item Count: d
itemCount;
printf
Grand Total of all marked up items: $f
grandTotal;
End program
return ;
This is my attempt to add functions to it would someone please help me
THIS PROGRAM DOES NOT USE FUNCTIONS; THE TASK IS TO REWRITE IT USING FUNCTIONS
Markupc by CIS
Input: Keyboard
Output: Screen
This program calculates markup price of an inventory item. Items are marked up by
An item count and grand total of the marked up values is accumulated and printed at the end
of the program. This program will include separate functions for: heading, inputs,
processing and outputs after it is restructured using functions.
#include
Prints HeadingWelcome Message
void printHeadingvoid;
Gets item number from user
int Numbervoid;
Gets item cost from user
float Costvoid;
Processing and calculating markup for a single item
float outputMarkupfloat;
Printing markup cost for a single item
void printmarkupfloat ;
int main void
Declaration
int itemNo itemCount;
float costf markedupf grandTotal f;
char again Y;
HeadingWelcome Message
printHeading;
Begin Loop
while again Y again y
get item number
itemNo Number;
get item cost
cost Cost;
get markedup
markedup outputMarkupcost;
accumulate grand total and count
itemCount;
grandTotal markedup;
print markup
printmarkupmarkedup;
Prompt user to determine if loop should continue
printfEnter another item? Enter Y or N ;
scanf c &again; note the space in the conversion specifier
Print count, final total
printf
;
printf
Item Count: d
itemCount;
printf
Grand Total of all marked up items: $f
grandTotal;
Heading
printfMarkup Calculator by You
;
End program
return ;
Definitions
Print heading welcome message
void printHeadingvoid
display heading
printfMarkup Calculator by Sarah Place
;
Input Section
Getting the item number from the user
int Numbervoid
int itemNo;
do
Validate entry
printf
Enter Item Number ;
scanfd &itemNo;
if itemNo itemNo
printfItem Number not accepted, enter an Item Number
;
while itemNo itemNo ;
return itemNo;
Getting cost of inventory item
float Costvoid
float costf;
printfEnter the cost of the inventory item ;
scanff &cost;
return cost;
Processing Section
float outputMarkup float Cost
float markupf;
markup cost f;
return outputMarkup;
Output Section
printf
The unit cost for item d is f
itemNo, cost;
printfThe marked up sales amount is f
markedup;
End Loop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
