Question

In: Computer Science

hello!! So this is my CIS assignment, my professor is very hard to understand and he...

hello!! So this is my CIS assignment, my professor is very hard to understand and he expects us to be perfect lol. I have tried to run this problem with a code but as you can see he wants to see that when the program is ran, all of the outcomes are listed all at once, the code that I have does meet the math part when it comes to the answers but as I said it does not show me all of my answers listed if not I have to put all of the inputs. also professor wants to see two different outcomes for example

income balance=-100

he wants to see income=nnnn

number of checks

bank fee=nnnn

in other words he wants to see me putting the income but he wants to see an additional.... (as part of the outcome)

I am really sorry but I have tried to go to tutoring and the time for me does not work......

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 that asks for the beginning balance and the number of check written. 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 transaction data file: transaction.txtPreview the documentPreview the document Output: Beginning balance: $-100 Number of checks written: 30 Your account is overdrawn! The bank fee this month is $27.40 Beginning balance: $400.00 Number of checks written: -20 Number of checks must be zero or more. Beginning balance: $300.00 Number of checks written: 36 The bank fee this month is $27.88 Beginning balance: $300.00 Number of checks written: 47 The bank fee this month is $27.82 Beginning balance: $350.00 Number of checks written: 5 The bank fee this month is $25.50 Beginning balance: $300.00 Number of checks written: 70 The bank fee this month is $27.80

Reading data from a file

# include <iostream>

# include <iomanip>

# include <fstream>

using namespace std;

std; int main()

{ ifstream input;

input.open("transaction.txt");

while (input>>balance>>check)//while loop

{

//Processing the checks }

}//end while loop

/////////// he also provided with this, to include in the program.

thanks! for the help I really appreciate it

few days ago I got this answer:

//Please like and comment

//code.cpp

# include <iostream>

# include <iomanip>

# include <fstream>

using namespace std;

int computeCharge(int balance)

{

int charge = 10;

if (balance < 400)

{

charge += 15;

}

return charge;

}

float computCheckFee(int numberOfChecks)

{

if (numberOfChecks < 20)

{

return numberOfChecks * 0.10;

}

else if (numberOfChecks >= 20 && numberOfChecks < 40)

{

return numberOfChecks * 0.08;

}

else if (numberOfChecks >= 40 && numberOfChecks < 60)

{

return numberOfChecks * 0.06;

}

else

{

return numberOfChecks * 0.04;

}

}

float computeFee(int balance, int numberOfChecks)

{

return computCheckFee(numberOfChecks) + computeCharge(balance);

}

void getResult(int balance, int checks)

{

if (checks < 0)

{

cout << " Number of checks must be zero or more" <<endl;

}

else if (balance < 0)

{

cout << " Your account is overdrawn! The bank fee this month is $" << computeFee(balance,checks)<< endl;;

}

else

{

cout << " The bank fee this month is $" << computeFee(balance, checks) << endl;

}

}

int main()

{

ifstream input;

input.open("transaction.txt");

int balance = 0, check = 0;

while (input >> balance >> check)//while loop

{

cout << "Beginning balance : $" << balance << " Number of checks written: " << check;

getResult(balance, check);

}//end while loop

return 0;

}

//output

but when I run the program if you take a look at it it has "float computeFee(int balance, int numberOfChecks)" this part seems to be the problem because when I run the problem it says the variables are not declared. pls I need help!

Solutions

Expert Solution

#include <iostream>

# include <iomanip>

# include <fstream>

using namespace std;

// change the data type of balance to float in every function parameter ( since balance may be in decimal)

int computeCharge(float balance)

{

int charge = 10;

if (balance < 400)

{

charge += 15;

}

return charge;

}

float computCheckFee(int numberOfChecks)

{

if (numberOfChecks < 20)

{

return numberOfChecks * 0.10;

}

else if (numberOfChecks >= 20 && numberOfChecks < 40)

{

return numberOfChecks * 0.08;

}

else if (numberOfChecks >= 40 && numberOfChecks < 60)

{

return numberOfChecks * 0.06;

}

else

{

return numberOfChecks * 0.04;

}

}

float computeFee(float balance, int numberOfChecks)

{

return computCheckFee(numberOfChecks) + computeCharge(balance);

}

void getResult(float balance, int checks)

{

if (checks < 0)

{

cout << " Number of checks must be zero or more" <<endl;

}

else if (balance < 0)

{

cout << " Your account is overdrawn! The bank fee this month is $" << computeFee(balance,checks)<< endl;;

}

else

{

cout << " The bank fee this month is $" << computeFee(balance, checks) << endl;

}

}

int main() {

       ifstream input;

       input.open("transaction.txt"); // provide full path to file

       float balance = 0; //make balance float as balance may be in decimal

       int check = 0;

       cout<<fixed<<setprecision(2);

       while (input >> balance >> check)//while loop

       {

       cout << "Beginning balance : $" << balance << " Number of checks written: " << check;

       getResult(balance, check);

       }//end while loop

       return 0;

}

//end of program

Output:

Input file:

The format of file is:

<beginning_balance><space><number_of_checks>

Each line consists of beginning_balance and number_of_checks separated by a space

Output:


Related Solutions

hello! So I have this CIS assignment lab but when I try to make the code...
hello! So I have this CIS assignment lab but when I try to make the code I don't really know where to start from. My professor is very hard and he likes to see the outcomes as they are shown in the problem. Please help me! Write a program that can be used as a math helper for an elementary student. The program should display two random integer numbers that are to be added, such as:     247 + 129...
PLEASE WORK THE PROBLEM STEP BY STEP. MY PROFESSOR IS A VERY HARD GRADER ALWAYS WANT...
PLEASE WORK THE PROBLEM STEP BY STEP. MY PROFESSOR IS A VERY HARD GRADER ALWAYS WANT STUDENT SHOW WORK. Sanders Corporation operates a factory in Arizona. Due to a change in business climate an impairment test is deemed appropriate. Management has acquired the following information: Cost $243,000,000 Accumulated depreciation 112,000,000 Estimate of the total undiscounted future cash flows 110,000,000 Present value of estimated future cash flows 94,000,000 Estimated fair value of the Arizona factory, as appraised 90,000,000 Required: a) Determine...
Validating Input file, So for my C++ assignment, my professor says we need to validate the...
Validating Input file, So for my C++ assignment, my professor says we need to validate the Input File, Which means, if the line is missing a comma, one of the 3 information, or the string is a white line, it will ignore it. If the line has a white line, the program will correct it and will read in the line. I will store these into an Array, and display them in First name, Last name, and Number of Votes...
Checking Input File for correct line format. So for my C++ assignment, my professor says we...
Checking Input File for correct line format. So for my C++ assignment, my professor says we need to validate the Input File, if there are white lines and spaces, in which it will ignore them, separated by a comma, and that all data items are there. This will be used in a program where i will store these into an Array, and display them in First name, Last name, and Number of Votes. This is a sample of the txt...
Checking Input File for correct line format. So for my C++ assignment, my professor says we...
Checking Input File for correct line format. So for my C++ assignment, my professor says we need to validate the Input File, if there are white lines and spaces, in which it will ignore them, separated by a comma, and that all data items are there. This will be used in a program where i will store these into an Array, and display them in First name, Last name, and Number of Votes vertical columned categories. This is a sample...
To my friendly student tax preparer: Hello, my name is Shady Slim. I understand you are...
To my friendly student tax preparer: Hello, my name is Shady Slim. I understand you are going to help me figure out my gross income for the year…whatever that means. It’s been a busy year and I’m a busy man, so let me give you the lowdown on my life and you can do your thing. I was unemployed at the beginning of the year and got $3,500 in unemployment compensation. I later got a job as a manager for...
Hello i am working on an assignment for my programming course in JAVA. The following is...
Hello i am working on an assignment for my programming course in JAVA. The following is the assignment: In main, first ask the user for their name, and read the name into a String variable. Then, using their name, ask for a temperature in farenheit, and read that value in. Calculate and print the equivalent celsius, with output something like Bob, your 32 degrees farenheit would be 0 degrees celsius Look up the celsius to farenheit conversion if you do...
Hello, I am having a hard time being able to fully understand how firm strategy, technology...
Hello, I am having a hard time being able to fully understand how firm strategy, technology and investment affects the emergence of the digital gaming industry? Please go into great detail.
So this is my assignment. My question is, what makes an object a good insulator? Does...
So this is my assignment. My question is, what makes an object a good insulator? Does having a high specific heat alone make a good insulator? Water has a very high specific heat, would it make a good insulator for the material? Please list off a bunch of common household items with why they are good insulators! Objective: Construct an insulated device that is designed to retain heat. Heated water will be put into a beaker and the beaker will...
Hi, so for my homework assignment, we are meant to change this function so that instead...
Hi, so for my homework assignment, we are meant to change this function so that instead of making a list from the array going up in an ascending order, making it be listed in descending order, meaning going from largest number to smallest number, the code I have now works for the ascending order, but how would I change this for it to go descending? Any help would be amazing, and please with a tutorial, thanks so much. def heapify(arr,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT