-3
コード割り当てがあります。セミコロンを既にC++に持っていても "ステートメントが見つからない;関数main()"になる
A bank charges $10 per month plus the following check fees for a commercial checking account:
$0.10 each for fewer than 20 checks
$0.08 each for 20-39 checks
$0.06 each for 40-59 checks
$0.04 each for 60 or more checks
The bank also charges an extra $15.00 if the balance of the account falls below $400 (before any check fees are applied). Write a program named lab2 that inputs for the beginning balance and the number of check written from the transaction file. Compute and display the bank's service fees for the month.
Input Validation: Do not accept a negative value for the number of checks written. If a negative value is given for the beginning balance, display an urgent message indicating the account is overdrawn.
The program should have a loop execution of six times for reading data from a file named transaction.txt.
Click the link transaction.txt download the file and store it in folder c:\cis180\lab2. The file transaction.txt contains the beginning balance and number of checks written for six transactions.
Here is the content of the file.
テキストファイル
-100.00 -beginningbalance
30 - number of checks
400.00
-20
300.00
36
300.00
47
350.00
5
300.00
70
私のコード
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <sstream>
//include a library file to input data from file
using namespace std;
bool isNumeric(string pszInput);
int main()
{//start
// Constants
int numChecks; // Number of checks written for the month
double acctBalance; // Account balance before subtracting check fees
double checkFee; // Fee based on number of checks written
double totalFees; // Total monthly bank fees
ifstream inputFile;
//Open the file
inputFile.open("c:\\cis180\\transaction.txt");
//Initialize month counter
int transaction = 0; //first month
//Create a loop to execute 6 times. Each time the loop body reads the beginning balance and number of checks for six transaction, calculate the bank fees, display the beginning balance, number of checks, and the bank fees.
inputFile >> acctBalance;
// Display the beginning balance
if (acctBalance>0)
{
cout<<"Your beginning balance is: "acctBalance << endl;
}
else (acctBalance<0)
{
cout<<"Your account is overdrawn!" << endl;
}
// Display the number of checks that were written.
if (numChecks>0)
{
cout<<"The number of checks written were: "numChecks<<endl;
}
else (numChecks<0)
{
cout<<"Number of checks must be 0 or more."<<endl;
}
// Determine whether the account is overdrawn.
// Validate number of checks written.
// If the number of checks is less than 0
{ // numChecks is valid, so we can calulate the fees.
// Calculate checkFee - Use if/else if structure
const double MONTHLY_FEE= 10.00; // Base monthly fee
const double MIN_BAL= 400.00; // minimum balance
const double LOW_BAL_FEE= 15.00; // extra fee for low balance
for (int transaction = 0; transaction <=6; transaction++);
if (numChecks<20)
{
checkFee=(0.1*numChecks)+MONTHLY_FEE<<endl;
}
else if (numChecks<40)
{
checkFee=(0.08*numChecks)+MONTHLY_FEE<<endl;
}
else if (numChecks<60)
{
checkFee=(0.06*numChecks)+MONTHLY_FEE<<endl;
}
else (numChecks>60)
{
checkFee=(0.04*numChecks)+MONTHLY_FEE<<endl;
}
// Calculate totalFees
if (numChecks<20 && acctBalance<MIN_BAL)
{
totalFees=checkFee+LOW_BAL_FEE<<endl;
}
else if (numChecks<40 && acctBalance<MIN_BAL)
{
totalFees=checkFee+LOW_BAL_FEE<<endl;
}
else if (numChecks<60 && acctBalance<MIN_BAL)
{
totalFees=checkFee+LOW_BAL_FEE<<endl;
}
else if (numChecks>60 && acctBalance<MIN_BAL)
{
totalFees=checkFee+LOW_BAL_FEE<<endl;
}
else (numChecks<20 && acctBalance>MIN_BAL)
{
totalFees=checkFee
}
// Display results: The bank fee
cout<<"The bank fee this month is "<<totalFees<<endl;
}//end the loop
return 0;
}//end
そして、私がコンパイルしようとすると、私はエラーを取得しています。
Error E2379 lab3.cpp 33: Statement missing ; in function main()
Error E2379 lab3.cpp 36: Statement missing ; in function main()
Warning W8004 lab3.cpp 115: 'transaction' is assigned a value that is never used in function main()
したがって、基本的に私の唯一の問題は既にタイトルにあります。助けてもらえますか?また、私はC++言語に新しいので、優しくしてください。他に問題がある場合は、私にそれを指摘できますか?前もって感謝します。
'cout <<"あなたの最初の残高は: "acctBalance << endl;'の先頭文字列と 'acctBalance'の間に' << 'がありません。そして 'else(acctBalance <0)'は 'else'のように' if'を欠いているように見えます。同様に 'else(numChecks <0)'と同様です。 [ここでは、言語リファレンスを持っている](http://en.cppreference.com/w/cpp/language) – WhozCraig
ここで既に述べたように、多くのエラーがあります: 'totalFees = checkFee'はセミコロンの後に' totalFees = checkFee; ' – EdChum
for(int transaction = 0; transaction <= 6; transaction ++);のセミコロンは1つの問題です。 – Bathsheba