Voting Process Program. It seems complicated for me but maybe easy for you.

So here is the algorithm (simplified only) This is a program that counts votes for a position(for this program a president). We'll call the person in charge of the program Myka.
Myka will enter the code to start the program which is 1234.
A. If it is correct , 1st Voter will be asked to enter their ID NUMBER. (in this case there are only 2 voters)
a. If ID number is correct. It will display the name of the voter and voting instructions. i. There are only 2 candidates for 1 position. ii. Once voting is done. It will display your vote has been counted.
b. If ID number is wrong, it will ask again. for the id number.
B. When the code entered is wrong it will ask again for the code.
When the Program reaches 2 voters, it will ask Myka again to enter the code. If it is wrong it will ask again and again until correct.
If it correct it will display all results.
There is also some conditions which makes it harder for me.
Once a single ID number is done voting, they could not vote ever again.
In the voting process, when a voter enters a number that is not 1 or 2. Then they will be asked to vote again for that specific position.
ive already started with what i only know how to do.
here is what i can only do http://www.reddit.com/r/NiceCopypaste/comments/1nkkiq/just_a_draft_for_a_program_dont_bother_opening_it/
pls help me. pls do write the codes.

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
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
int main()
{
    int code, idnumber, vote, trueshit=0, holyshit=0;
    
    printf(" \n Please enter the code to start the program.\n\n ");
    scanf("%d",&code);
    
    switch(code)
    {
                case 1234:
                     
                     printf(" \n Enter your ID Number. \n \n ");
                     scanf("%d",&idnumber);
                     
                     switch(idnumber)
                     {
                                     case 1111:
                                          
                                          printf(" Makakashi \n ");
                                          printf(" Press 1 to vote for the 1st candidate, 2 to vote for the 2nd. \n\n");
                                          printf(" 1. Holy Shit 2. True Shit \n");
                                          scanf("%d",&vote);
                                          
                                          switch(vote)
                                          {
                                                      case 1:
                                                           holyshit=holyshit + 1;
                                                           break;
                                                           
                                                           case 2:
                                                                trueshit=trueshit + 1;
                                                                break;
                                                                
                                                                default:
                                                                        printf(" When I press a number equal or less than to zero or greater than or equal to three. It should go back to ask to vote again. ");
                                                                        }
                                                                        printf(" Thank you for voiting ! \n");
                                                                        break;
                                                                        
                                                                        
                                                                        case 2222:
                                                                             printf(" Marimari \n ");
                                                                             printf(" Press 1 to vote for the 1st candidate, 2 to vote for the 2nd. \n\n");
                                                                             printf(" 1. Holy Shit 2. True Shit \n");
                                                                             scanf("%d",&vote);
                                          
                                                                             switch(vote)
                                                                             {
                                                                                            case 1:
                                                                                                 holyshit=holyshit + 1;
                                                                                                 break;
                                                           
                                                                                                 case 2:
                                                                                                      trueshit=trueshit + 1;
                                                                                                      break;
                                                                
                                                                                                      default:
                                                                                                       printf(" When I press a number equal or less than to zero or greater than or equal to three. It should go back to ask to vote again. ");
                                                                                                       }
                                                                                                       printf(" Thank you for voiting ! \n");
                                                                                                       break;
                                                                                                       
                                                                                                       
                                                                                                       default:
                                                                                                               printf("Invalid Number \n");
                                                                                                               }
                                                                                                               break;
                                                                                                               
                                                                                                               default:
                                                                                                                       printf("Invalid code \n");
                                                                                                                       }       
                                                                                                                       system("pause");
                                                                                                                       }                                                                                                                
                                                                                                               
                                                                                                 
                                                                        
                                                      
                                                           
Last edited on
I would use a struct to create a voter ID account.
This struct must hold their information such as their name and ID number.

You can also store whom they voted for. Or no one if they have not yet voted.

Once you have the struct objects, the rest of the code should be easy, just some void functions that take the struct objects by reference and can alter the data contained within the structs. A few 'cout' commands to prompt the user for input and a while loop to make sure they are inputting valid data.

Good luck.
LOL. Im sorry. Im really new to this and I dont understand what you're saying.

But thanks though. As you can see I used codes that are easy to use.
Last edited on
well the reason your code does not loop back to the beginning is because there is no loop in your program.

you could use a 'for' loop or a 'while' loop. But you will need some form of loop to go back to the top and start again. Switches do not by themselves create loops.
Topic archived. No new replies allowed.