Fermé

programming assignment 2

(1 mark) Write a function calculateItemCost prototyped by

double calculateItemCost(double itemPrice, char discountType, unsigned quantity);

so that the execution of this function will return the price for quantity number of the item priced originally at itemPrice each, and currently discounted according to discountType. For instance, calculateItemCost(10.90, 'D', 2) will return 17.44 because 17.44=10.9*0.8*2. Likewise calculateItemCost(5.50, 'B', 4) will return the value 19.8=5.50*0.9*4.

Write a driver program to illustrate the use of this function calculateItemCost unless the illustration will be done in your complete program jewelrySale.cpp.

(1 mark) Write a function displayTotalCost prototyped by

void displayTotalCost(double totalCost, unsigned recordNum, bool aborted);

so that the execution of this function will first display the total sale cost stored in variable totalCost and the total number of sale records stored in recordNum. If aborted is true, then the function will also display an error message to the effect "Input terminated by invalid data at record" followed by the corresponding record value. For example, displayTotalCost(55.55, 3, false) could just display

Total sale cost (3 records) = $55.55

while displayTotalCost(66.66, 7, true) could display

Total sale cost (7 records) = $66.66

Input terminated by invalid data at record 8.

Write a driver program to illustrate the use of this function displayTotalCost unless the illustration will be done in your complete program jewelrySale.cpp.

(2 marks) Write a function readSaleRecord prototyped by

int readSaleRecord(unsigned & itemId, double & itemPrice,

char & discountType, unsigned & quantity);

so that the execution of this function will retrieve 4 fields, i.e. the item ID itemId, the original item price itemPrice, the discount type discountType and the quantity quantity, from the stdin device. The returned value will be 0 if the reading has been successful, and will be non-zero if otherwise. In fact, when the record is not successfully read, the returned value will be 1 if it's due to receiving 0 for the item ID or hitting the EOF, and will be -1 if otherwise.

Explain (i) what do the ampersands "&" do in the prototyping; (ii) is this function still syntactically correct if some of these 4 ampersands are removed from the function header; and (iii) will your program still work if one of these 4 ampersands is removed and why. Please also use the following interface for the input.

Enter

-> item ID: 101024

-> full item price: 199.95

-> discount type: D

-> quantity: 1

Write a driver program to illustrate the use of this function readSaleRecord unless the illustration will be done in your complete program jewelrySale.cpp.

(1 marks) Complete the rest of the program to fulfill all the program requirements for the problem described in this PART I. For your reference, below is the screenshot of executing a possible implementation.

Enter

-> item ID: 101023

-> full item price: 149.95

-> discount type: B

-> quantity: 1

Enter

-> item ID: 101024

-> full item price: 199.95

-> discount type: D

-> quantity: 1

Enter

-> item ID: 100001

-> full item price: 19.99

-> discount type: N

-> quantity: 5

Enter

-> item ID: 100002

-> full item price: 39.99

-> discount type: N

-> quantity: 2

Enter

-> item ID: 103067

-> full item price: 1999

-> discount type: T

-> quantity: 1

Enter

-> item ID: 0

Total sale cost (5 records) = $1874.15

(1 mark) Draw the Structure Diagram for your solution algorithm. Please beware that your complete C++ program for this PART I needs to match this structure diagram.

Compétences : Programmation C++

Voir plus : write function displaytotalcost prototyped, syntactically correct function header, function syntactically correct ampersands removed function header, draw structure diagram solution algorithm, double calculateitemcost double, write driver program illustrate use function readsalerecord, write function display total cost prototyped, write driver program illustrate use function displaytotalcost, write function readsalerecord, programming assignment, why data structure, what's an algorithm, what's algorithm, what is structure in cpp, what is record in data structure, what is programming, what is data structure in programming, what is a variable in programming, what is a programming algorithm, what is an interface in programming, what is an assignment problem, what is an algorithm in programming, what is algorithm in programming, what is algorithm in data structure, what is a function in programming

Concernant l'employeur :
( 0 commentaires ) Australia

N° du projet : #1668185

29 freelance ont fait une offre moyenne de 34 $ pour ce travail

srinichal

I can deliver the project

80 $ AUD en 2 jours
(31 Commentaires)
5.9
it2051229

Hi, kindly check your inbox for my inquiries. Thanks.

30 $ AUD en 1 jour
(84 Commentaires)
5.3
rakib062

Hi, I am a graduate in CS with major in Data structure and algorithms with 3+ years of experience of professional app development in C++. I have done lots of similar assignment both in academic courses and in freelanc Plus

50 $ AUD en 1 jour
(18 Commentaires)
4.2
pkcoder

Hi. I am a qualified programmer. I can do this job. kindly check pmb for details. thank you

30 $ AUD en 0 jours
(11 Commentaires)
3.9
egypro

please check PM

30 $ AUD en 0 jours
(7 Commentaires)
3.8
nguyenquoc

i have 5 year in C++ program, i can complete this ass very [url removed, login to view], check pmb

30 $ AUD en 0 jours
(6 Commentaires)
3.7
aleexaibi

hi, i am expert in C++ ... confident to do the job :)

40 $ AUD en 0 jours
(16 Commentaires)
3.6
hddh

I can do it.

30 $ AUD en 0 jours
(8 Commentaires)
3.4
minhtridn2001

I'm C,C++ expert. I'm surely satisfy you. Please accept my bid. Thanks

30 $ AUD en 0 jours
(6 Commentaires)
3.1
pivn

Let me do it for yout

40 $ AUD en 1 jour
(3 Commentaires)
1.8
junaidsubhani

its so simple i can do it

30 $ AUD en 0 jours
(0 Commentaires)
0.0
paulbota

I am an experimented c/c++ programmer. I can do this easy.

30 $ AUD en 1 jour
(0 Commentaires)
0.0
renugupta27

Please confirm when to start

30 $ AUD en 3 jours
(0 Commentaires)
0.0
faiyaz26bd

Hello, I am new on [url removed, login to view] but i am not a n old c++ coder. I can finish this job easily within 1-2 days. I am an ACM programmer, so doing this kind of task is so easy for me. Hope you will like my price. Plus

30 $ AUD en 2 jours
(0 Commentaires)
0.0
gshailesh10

I have years of work experience in C++.

30 $ AUD en 3 jours
(0 Commentaires)
0.0
jamesakendall

I have it nearly done. Just waiting for your response. Jim

30 $ AUD en 1 jour
(0 Commentaires)
0.0
tallal300

i can do that in no time!:P

35 $ AUD en 1 jour
(0 Commentaires)
0.0
khucamdia

I'm C,C++ expert. I'm surely satisfy you. Please accept my bid. Thanks

35 $ AUD en 0 jours
(0 Commentaires)
0.0
randezvous

Sir, I can do this project right away. Please do consider my bid. Thanks, Rand

30 $ AUD en 0 jours
(0 Commentaires)
0.0
MuneebAtta

I will do it for 30 $ and provide you with your work with in one day.

30 $ AUD en 1 jour
(0 Commentaires)
0.0