저는 일반적으로 C ++ 및 개발에 익숙하지 않습니다. 솔직히 나는 무슨 일이 일어나고 있는지 전혀 모른다. 한 줄에 문자열을 표시하려고하는데 프로그램에서 혼란스러운 오류가 발생합니다.
도움을 주시면 감사하겠습니다.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
// This program calculates and displays to user
int main()
{
// Constants are state and county taxes.
const float STATE_TAX_RATE = 0.04,
COUNTY_TAX_RATE = 0.02;
// float variables are :
float gross_sales = 0,
net_sales = 0,
county_tax_payment = 0,
state_tax_payment = 0,
total_tax_payment = 0;
// string variable
string month;
// integer variable
int year;
// Get month, year, and sales information from user
cout << "For what month is this? (Please type the name of the month.)\nAnswer: ";
getline(cin, month);
cout << "For what year?\nAnswer: ";
cin >> year;
cout << "How much was total sales at the register?\nAnswer: ";
cin >> gross_sales;
// Calculate the net income
net_sales = (gross_sales)/(1 + STATE_TAX_RATE + COUNTY_TAX_RATE);
// Calculate total taxes paid.
total_tax_payment = (gross_sales - net_sales);
// cout << total_tax_payment; // output test
// Calculate total state taxes paid.
state_tax_payment = (total_tax_payment * (2.0/3.0));
// cout << state_tax_payment; //output test
// Calculate county taxes paid.
county_tax_payment = (total_tax_payment * (1.0/3.0));
//Display the information
cout << "Month: " << month << " " << year << endl;
cout << "--------------------" << endl;
cout << "Total collected:\t $" << fixed << setw(9) << setprecision(2) << right << gross_sales << endl;
cout << "Sales: \t\t\t\t $" << fixed << setw(9) << setprecision(2) << right << net_sales << endl;
cout << "County Sales Tax:\t $" << fixed << setw(9) << setprecision(2) << right << county_tax_payment << endl;
cout << "State Sales Tax:\t $" << fixed << setw(9) << setprecision(2) << right << state_tax_payment << endl;
cout << "Total Sales Tax:\t $" << fixed << setw(9) << setprecision(2) << right << total_tax_payment << endl;
return 0;
}
출력은 다음과 같습니다.
이것은 몇 달 동안입니까? (월 이름을 입력하세요.)
답변 : 3 월
몇 년 동안?
답변 : 2008
계산대에서 총 판매량은 얼마입니까?
답변 : 26572.89
(lldb)
"(lldb)"에서 프로그램이 중지되고 Xcode는 "cout <<"Month : "<< month <<" "<< year << end;"에서 이해할 수없는 것을 나타냅니다. 문제는 많은 복잡한 디버깅 정보입니다. 표시기는 녹색입니다.
도움을 주셔서 다시 한번 감사드립니다 !!!
실제 문제는 Tony D.
Xcode의 디버거에는 특정 코드 줄로 설정된 중단 점이 있습니다. 나는 단지 그것을 거터 밖으로 끌어 내야 만했다. 모르는 사람들에게는 코드 줄의 왼쪽에있는 녹색 화살표가 중단 점입니다. 제거하려면 코드에서 아래쪽으로 드래그하십시오.
나는 내가 하나이기 때문에 완전히 새로운 실수를 저질렀지만 교훈을 얻었습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다