我的输出没有显示 [英] My output isn't showing

查看:126
本文介绍了我的输出没有显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是这个世界的新手,现在在学校,我的代码看起来不错,但是控制台没有产生我想要的合适输出。寻找帮助,找出为什么以及如何在将来避免这种情况。



提前感谢您的帮助。



Brandon



Hello everyone, I am new to this world, at school right now and my code looks good, but the console isn't producing the appropriate output that I was looking for. Looking for help in figuring out why and how I can avoid this in the future.

Thanks in advance for all your help.

Brandon

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
	ifstream inFile;
	ofstream outFile;

	inFile.open("inData.txt");
	outFile.open("outData.txt");

	string firstName, lastName, name, department;
	double monthlySalary, monthlyBonus, amountBonus, totalIncome, taxes, taxRate, payCheck, distanceTraveled, travelingTime, averageSpeed, coffeeCost, coffeeSales;

	int cupsSold;

	outFile << fixed << showpoint << setprecision(2);
	inFile >> firstName >> lastName >> department;
	name = firstName + lastName;
	outFile << "Name: " << name << ", Department: " << department << endl;

	inFile >> monthlySalary >> monthlyBonus >> taxes;
	amountBonus = (monthlySalary) * (monthlyBonus / 100);
	totalIncome = monthlySalary + amountBonus;
	taxRate = (totalIncome) * (taxes / 100);
	payCheck = totalIncome - taxRate;
	outFile << "Monthy Gross Salary: $" << monthlySalary << ", Monthly Bonus: " << monthlyBonus << "%" << ", Taxes: " << taxes << "%" << endl;
	outFile << "Paycheck: $" << payCheck << endl;

	inFile >> distanceTraveled >> travelingTime;
	averageSpeed = distanceTraveled / travelingTime;
	outFile << "Distance Traveled: " << distanceTraveled << " miles" << ", Traveling time: " << travelingTime << " hours" << endl;
	outFile << "Average Speed: " << averageSpeed << " miles per hour" << endl;

	inFile >> cupsSold >> coffeeCost;
	coffeeSales = cupsSold * coffeeCost;
	outFile << "Number of Coffee Cups Sold: " << cupsSold << ", Cost: $" << 1.50 << " per cup" << endl;
	outFile << "Sales Amount: $" << coffeeSales << endl;

	inFile.close();
	outFile.close();

	return 0;
}





我的尝试:



我一直在回头几次重做所有事情而不回头看我之前写的东西,希望我错过了什么,但我想我已经达到了我的专业水平。



输出应该告诉我:



姓名:Giselle Robinson,部门:会计

每月总薪水:$ 5600.00,每月奖金:5.00%,税金:30.00%

薪水支票:$ 4116.00



行程距离: 450.00英里,旅行时间:9.00小时

平均速度:每小时50.00英里

已售出的咖啡杯数量:75,成本:每杯1.50美元

销售金额= $ 112.50



但我只能得到:





C:\ Users \ Brandon Ness \source \repos\CS265_BNess_Week2_Assignment\Week 2 Project\Release\Week 2 Project.exe(进程25488)退出,代码为0.

要在调试停止时自动关闭控制台,请启用Tools-> Options-> Debugging->调试停止时自动关闭控制台。

按任意键关闭此窗口。 。 。



What I have tried:

I have been going back and redoing everything several times without looking back at what I wrote before, in hopes that I have missed something, but I think I have met my level of expertise on it.

The output should show me:

Name: Giselle Robinson, Department: Accounting
Monthly Gross Salary: $5600.00, Monthly Bonus: 5.00%, Taxes: 30.00%
Paycheck: $4116.00

Distance Traveled: 450.00 miles, Traveling Time: 9.00 hours
Average Speed: 50.00 miles per hour
Number of Coffee Cups Sold: 75, Cost: $1.50 per cup
Sales Amount = $112.50

BUT I only get:


C:\Users\Brandon Ness\source\repos\CS265_BNess_Week2_Assignment\Week 2 Project\Release\Week 2 Project.exe (process 25488) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

推荐答案

<< monthlySalary<< ,每月奖金:<< monthlyBonus<< << ,Taxes:<< taxes< < << endl;
outFile<< 薪水支票:
" << monthlySalary << ", Monthly Bonus: " << monthlyBonus << "%" << ", Taxes: " << taxes << "%" << endl; outFile << "Paycheck:


<< payCheck<< endl;

inFile>> distanceTraveled>> travelingTime;
averageSpeed = distanceTraveled / travelingTime;
outFile<< 行进距离:<< distanceTraveled<< miles<< ,旅行时间:<< travelingTime<< hours<< ENDL;
outFile<< 平均速度:<< averageSpeed<< 每小时英里数<< ENDL;

inFile>> cupsSold>> coffeeCost;
coffeeSales = cupsSold * coffeeCost;
outFile<< 已售出的咖啡杯数量:<< cupsSold<< ,Cost:
" << payCheck << endl; inFile >> distanceTraveled >> travelingTime; averageSpeed = distanceTraveled / travelingTime; outFile << "Distance Traveled: " << distanceTraveled << " miles" << ", Traveling time: " << travelingTime << " hours" << endl; outFile << "Average Speed: " << averageSpeed << " miles per hour" << endl; inFile >> cupsSold >> coffeeCost; coffeeSales = cupsSold * coffeeCost; outFile << "Number of Coffee Cups Sold: " << cupsSold << ", Cost:


<< 1 50 << 每杯<< ENDL;
outFile<< 销售额:
" << 1.50 << " per cup" << endl; outFile << "Sales Amount:


这篇关于我的输出没有显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆