Assignment due at 5pm uk time, how do you do make valid and invalid data work in c++ menu

Assignment due at 5pm uk time ASAP HELP

Please help me to find my errors!!

the valid is not working please help!!





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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <limits>

void draw_menu()
{
    std::cout << "******************************************************************\n"
              << "* choose an entry from 1 to 3.  *\n"
              << "* [1] validate modulus 11 number  *\n"
              << "* [2] validate data  *\n"
              << "* [3] quit  *\n"
              << "******************************************************************\n";
}

int get_number() // read a valid number from stdin
{
    int number ;
    if( std::cin >> number ) return number ;

    // invalid input, inform the user, clear the input buffer and try again
    std::cout << "invalid number. please re-enter\n" ;
    std::cin.clear() ;
    std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
    return get_number() ;
}

int get_choice() // display the menu, return valid choice entered by the user
{
    draw_menu() ;

    const int choice = get_number() ;
    if( choice >= 1 && choice <= 3 ) return choice ; // valid choice

    return get_choice() ; // invalid choice, try again
}

bool valid_date( int dd, int mm, int yy )
{
   // validation
 if (dd, mm, yy)
 int month [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    if (yy % 4 == 0)

    return false ;
}


bool valid_modulo_11( int number )
{
    // *** TO DO: validate that number is a valid modulo 11 number
    //            if valid, return true

    return false ;
}

int main()
{
    bool quit = false ;

    do
    {
        const int choice = get_choice() ;

        switch(choice)
        {
            case 1:
            {
                std::cout << "enter modulo 11 number: " ;
                const int number = get_number() ;

                if( valid_modulo_11(number) ) std::cout << "yes, valid modulo 11 number\n" ;
                else std::cout << "that is not a valid modulo 11 number\n" ;

                break ;
            }

            case 2:
            {
                std::cout << "enter day: " ;
                const int dd = get_number() ;
                std::cout << "enter month: " ;
                const int mm = get_number() ;
                std::cout << "enter year: " ;
                const int yy = get_number() ;

                if( valid_date( dd, mm, yy ) ) std::cout << "valid date\n" ;
                else std::cout << "invalid date\n" ;

                break ;
            }

            case 3: quit = true ;
        }

    } while( !quit ) ;
}

help asap

Last edited on
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/general/192758/
http://www.cplusplus.com/forum/general/192757/
.http://www.cplusplus.com/forum/general/192756/
Last edited on
that is my friend from my class his one isnt working aswell
Topic archived. No new replies allowed.