Question

In: Computer Science

If answer can be shown using a c++ program and leave comments it will be very...

If answer can be shown using a c++ program and leave comments it will be very appreciated!!!

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.

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

Solutions

Expert Solution

If you have any problem with the program feel free to comment

Program

#include <iostream>
#include <stdlib.h>

using namespace std;

float calculateCheckFee(int);

int main(){
float perMonthCharge = 10;
float extraCharge = 15;

float balance, bankFee;
int numberOfChecks;

//taking inputs from user
cout<<"Beginning balance: $";
cin>>balance;

cout<<"Number of checks written: ";
cin>>numberOfChecks;

//checking balance validity
if(balance < 0){
cout<<"Your account is overdrawn!"<<endl;
bankFee = perMonthCharge + extraCharge;
}
else if(balance > 0 && balance < 400){
bankFee = perMonthCharge + extraCharge;
}
else{
bankFee = perMonthCharge;
}

//checking number of checks validity
if(numberOfChecks < 0){
cout<<"Number of checks must be zero or more.";
exit(0) ;
}

bankFee += calculateCheckFee(numberOfChecks);

cout<<"The bank fee this month is $"<<bankFee;
}
//calculating check fee
float calculateCheckFee(int numberOfChecks){
float checkFee;

//getting the check fee according to given range
if(numberOfChecks < 20){
checkFee = 0.10;
}
else if(numberOfChecks>= 20 && numberOfChecks<= 39){
checkFee = 0.08;
}
else if(numberOfChecks>= 40 && numberOfChecks<= 59){
checkFee = 0.06;
}
else{
checkFee = 0.04;
}
return checkFee * numberOfChecks;//calculating total check fee and returning
}

Output


Related Solutions

C PROGRAM STRING AND FILE PROCESSING LEAVE COMMENTS! I WILL LEAVE POSITIVE REVIEW! THANK YOU :)...
C PROGRAM STRING AND FILE PROCESSING LEAVE COMMENTS! I WILL LEAVE POSITIVE REVIEW! THANK YOU :) I need a program that 1) Count all words in a file. A word is any sequence of characters delimited by white space or the end of a sentence, whether or not it is an actual English word. 2)Count all syllables in each word. To make this simple, use the following rules: •Each group of adjacent vowels (a, e, i, o, u, y) counts...
write a c# program that: The file is using a very simple form of compression in...
write a c# program that: The file is using a very simple form of compression in which there are no spaces, each word is separated by camel casing. For Example, the string "TheCatWillRun" is parsed as "The Cat Will Run". *Now for the statistics* Prints to the console the following statistics about the content in the file retrieved above. - How many of each letter are in the file - How many letters are capitalized in the file - The...
hi,I have this C++ program,can someone add few comments with explanation what is the logic and...
hi,I have this C++ program,can someone add few comments with explanation what is the logic and what is what?thank you I m total beginner #include <iostream> using namespace std; int ArraySum(int MyArray[], int size){ int* p = MyArray; int sum = 0; while(p<MyArray+size){ sum += *p; p++; } return sum; } int main() { int MyArray[10] = {4, 0, 453, 1029, 44, 67, 111, 887, 4003, 1002}; cout<<ArraySum(MyArray,10); return 0; }
In C++ fill in the comments the easiest to get the program work and get this...
In C++ fill in the comments the easiest to get the program work and get this output. Sample Output Please input the x: 2.5 Please input the y: -5 Please input the x: 3 Please input the y: 7.5 You entered: ( 2.5, -5 ) and ( 3, 7.5 ) point3 is ( 2.5, -5 ) Press any key to continue . . . #include <iostream>   // For cout and cin #include <iomanip>    // For formatting output, e.g. setprecision #include...
Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
Please write a complete C coding program (NOT C++) that has the following: (including comments) -...
Please write a complete C coding program (NOT C++) that has the following: (including comments) - declares two local integers x and y - defines a global structure containing two pointers (xptr, yptr) and an integer (z) - declares a variable (mst) by the type of previous structure - requests the values of x and y from the user using only one scanf statement - sets the first pointer in the struct to point to x - sets the second...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2...
*Answer in C program* Given a program as shown below: #include <stdio.h> void function1(void); void function2 (int, double x); void main (void) { int m; double y; m=15; y=308.24; printf ("The value of m in main is m=%d\n\n",m); function1(); function2(m,y); printf ("The value of m is main still m = %d\n",m); } void function1(void) { printf("function1 is a void function that does not receive\n\\r values from main.\n\n"); } void function2(int n, double x) { int k,m; double z; k=2*n+2; m=5*n+37;...
I need to complete this C++ program. The instructions are in the comments inside the code...
I need to complete this C++ program. The instructions are in the comments inside the code below: ------------------------------------------------------------------------- Original string is: this is a secret! Encypted string is: uijt!jt!b!tfdsfu" Decrypted string is: this is a secret! //Encoding program //Pre-_____? //other necessary stuff here int main() { //create a string to encrypt using a char array cout<< "Original string is: "<<string<<endl; encrypt(string); cout<< "Encrypted string is: "<<string<<endl; decrypt(string); cout<<"Decrypted string is: "<<string<<endl; return 0; } void encrypt(char e[]) { //Write implementation...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
Done in C language using mobaxterm if you can but use basic C This program is...
Done in C language using mobaxterm if you can but use basic C This program is broken up into three different functions of insert, delete, and main. This program implements a queue of individual characters in a circular list using only a single pointer to the circular list; separate pointers to the front and rear elements of the queue are not used. The linked list must be circular.      The insert and remove operations must both be O(1)    You...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT