A few questions from a beginner

I need to write a program for class that estimates a budget. I am supposed to only return 2 decimal points in my answer (after the initial whole amount like 359.00) and only allow 2 decimal points to be typed. I don't really know how to go about doing this.

Also, how do I allow multiple characters to be assigned to 1 menu item? Like if the person wants to start the initial program, i am supposed to let them type 1,y,Y,P,p,B,b,N,n

Any help is greatly appreciated

Edit: Also I am supposed to allow them to type the $ in front OR in back of the value if they want to.
Last edited on
please post your code / whatever you've done by now...
I just started this a little bit ago.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <limits.h>
#include <cmath>
using namespace std;

double
{
    double  
}

int main ()
{
    int choice;
    bool run;
    while (run != false)
        {
            cout << "Welcome to the Budget Program";
            cout << "\n1) Next Year Budget Projection\n";
            cout << "2) Coin Flip!\n";
            cout << "3) Exit\n";
            cout << "Enter Your Choice And Press Enter: ";
            cin >> choice;
    
        }
    
    switch (choice)
        {
            case 1:
            
            double current_budget;
            double spent_budget;
            
            cout << "Please enter your allowed budget for this year: "
            cin >> current_budget;
            cin.ignore(INT_MAX, '\n'); 
            
            cout << "Please enter how much you spent this year: "
            cin >> spent_budget;
            cin.ignore(INT_MAX, '\n');
        }
}


The professor also wants us to use our own functions, hence why there is a "double" at the top, i just don't know what im gonna put in there yet.
Last edited on
Topic archived. No new replies allowed.