Please HELP! Desperate Student

Hello Everyone. I have this take home exam and I am stuck on one of the questions. I'm super desperate, please help. I'm a beginner at C++. This exam is due on Monday (March 18th). I am using Qunicy 2005 since that's what we have been using in class. Below is the program that I need to create. Thanks in advance for your time and consideration:


Write a program that will input the following data:
Last month’s balance (float)
Total deposit for the month (float)
Total amount of checks written for the month (float)
And calculate the following:

New balance – last months balance + total deposits – checks – SERVICE_CHARGE

Requirements for the program to be written:

• The program must prompt the user for the above input from the keyboard. The Service charge must be defined using a symbolic constant and assigned a value of $10.00 (the service charge is a flat $10 per month).

• The program must call a function, passing the input, and calculate the new balance. The new balance must be returned to main().


• Output must occur in a function called Output. This function is to clear the screen and display the following, where xxx.xx refers to the inputted values or calculated values.

Balance last month: xxxx.xx
Total deposits for month: xxxx.xx
Total checks for month: xxxx.xx
Service charge: 10.00
New Balance: $ xxxx.xx

• The program should prompt the user to continue (C) or Quit (Q). Consequently, you must use a loop until the user enters a Q to Quit. If the user enters anything other than a C or Q, signify an error exists in input and give the user a second chance for the input of a C or Q.

• If the New Balance is less than or equal to zero (0), display an error message to the right of the line displaying New Balance: $ xxxx.xx

• Such as: New Balance: $ xxxx.xx – Balance Insufficient

• Output all numeric values to 2 decimal places and be sure to place the $ in the line displaying the New Balance.

• You must turn in a cover sheet, followed by this assignment sheet, a copy of the source code, and a copy of the output.
Here, I'll start you off.

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
    //Code goes here
    return 0;
}
closed account (D4S8vCM9)
If it would not be so narrow in time I would help, since it is a quite simple thing (but I'm tired now).

New balance – last months balance + total deposits – checks – SERVICE_CHARGE

is a bit strange formula :-P

A bit lengthy is all that UI stuff, but the "function" could be like that:

1
2
3
4
float calcBalance(float lmBalance, float deposits, float checks) const {
  const float SERVICE_CHARGE = 10.0f;
  return lmBalance + deposits – checks – SERVICE_CHARGE;
}

Write it just above the main and you don't need an extra declaration for it.

UI stuff you must ask somebody else for help.
Here are the two functions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 double new_bal(double lm_bal,double m_deposit,double cheque_val)
{
    double new_balance=(lm_bal+m_deposit-cheque_val-SERVICE_CHARGE);
    return new_balance;
}
void output(double lm_bal,double m_deposit,double cheque_val,double new_ball)
{
    using namespace std;
    cout<<"\nBalance last month:       "<<lm_bal<<endl;
    cout<<"Total deposits for month: "<<m_deposit<<endl;
    cout<<"Total cheques for month:  "<<cheque_val<<endl;
    cout<<"Service Charge:            "<<SERVICE_CHARGE<<endl;
    cout<<"New Balance:              "<<new_ball;
    if(new_ball<0)cout<<"-Balance Insufficient";
}

...and here is the loop in main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
do
   {cout<<"\n";
   cout<<"enter last month's balance               ";
   cin>>lm_bal;
   cout<<"enter deposits for month                 ";
   cin>>m_deposit;
   cout<<"enter value of cheques written for month ";

   cin>>cheque_val;
   new_ball=new_bal(lm_bal,m_deposit,cheque_val);
   //cout<<"the new balance is $"<<new_ball;
   output(lm_bal,m_deposit,cheque_val,new_ball);
   char ans;
   cout<<"\nto continue enter c (q to quit)";
   cin >>ans;
   if(ans=='q' || ans== 'Q' )
   return 0;
   }while(ans!='q');

...don't forget to setprecision(2) above the loop which is defined in the iomanip header file.
I ask specific questions about syntax and logical rules of arrays and nobody helps. But people are lining up to do this guy's homework for him when he hasn't even asked a question... Lovely.
closed account (Dy7SLyTq)
actually army-gal so pretty sure its a girl. second, people did answer them. third, its rude to hijack a post that is in the progress of being answered
closed account (D4S8vCM9)
Girls/ladies are too much underrepresented in software engineering :-(

Beside the normal girl factor it is proven that females have a better understanding of logic (scientific!) and maths. So I guess they could be of great value if they wouldn't have this strange thinking of what software engineering is.

(But their smart phones they can handle often better than any male)
Topic archived. No new replies allowed.