问题描述
/* Program: prog3.cpp
By: Mackenzie Ritter
Last Modified: Oct 31, 2017
Purpose: To give customer their cost based on amount of books purchased.
Notes:
*/
#include
#include
using namespace std ;
void Instructions () ;
void numBooks () ;
void totalCost (int) ;
void percentoff (float) ;
void finalCost (float, float) ;
void receipt (int, float, float, float) ;
int main ()
{
int books ;
float total, cost, discount ;
Instructions () ;
numBooks () ;
totalCost (books) ;
percentoff (total) ;
finalCost (discount, total) ;
receipt (books, total, discount, cost) ;
}
void Instructions ()
{
cout > books ;
}
void totalCost (int books)
{
float total = books * 8.99 ;
}
void percentoff (float total)
{
float discount = 0.15 * total ;
}
void finalCost (float discount, float total)
{
float cost = total - discount ;
}
void receipt (int books, float total, float discount, float cost)
{
cout << books << endl ;
cout << "$" << total << endl ;
cout << discount << "% off" << endl ;
cout << "$" << cost << endl ;
}
我的尝试:
我试过调整参数因为我认为我以前错了。当我运行程序时,它给了我奇怪的输出。例如,当它要求我提供一些书籍时,我将输入2并且程序将给予
-2091432192
$ 4.59163e-41
0%off
$ 0
如果你能帮助我,我将不胜感激。
What I have tried:
I have tried adjusting the parameters because I believe I had them wrong before. When I run the program, it gives me strange output. For example, when it asks me for a number of books, I will enter 2 and the program will give
"-2091432192
$4.59163e-41
0% off
$0"
If you could help me, I would greatly appreciate it.
推荐答案
我尝试了什么:
我试过调整参数因为我相信我有它们以前错了。当我运行程序时,它给了我奇怪的输出。例如,当它要求我输入一些书时,我将输入2并且程序将给出
-2091432192
What I have tried:
I have tried adjusting the parameters because I believe I had them wrong before. When I run the program, it gives me strange output. For example, when it asks me for a number of books, I will enter 2 and the program will give
"-2091432192
这篇关于我如何得到正确的答案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!