In: Computer Science
(Use C++ language) CREATE A PROGRAM CALLED and or not.cpp THAT: ASKS USER FOR AGE Note: you must be 18 or older to vote && is the symbol for And | | is the symbol for Or ! is the symbol for Not USE AND, OR, OR NOT TO SEE IF THEY'RE OLD ENOUGH TO VOTE and display appropriate message USE AND, OR, OR NOT TO SEE IF THEY ENTERED A NUMBER LESS THAN 0 and display appropriate message USE AND, OR, OR NOT TO SEE IF THEY ENTERED 18 or higher and display appropriate message DISPLAY A MENU OF CHOICES: 1. Democrat 2. Republican 3. Independent ASK USER TO ENTER THE NUMBER OF THEIR CHOICE USE IF STATEMENT WITH == TO CHECK THEIR CHOICE use a different message for each choice if they enter something other than 1,2, or 3 use AND, OR, or NOT to find out display a message
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.
Let me know for any help with any other questions.
Thank You!
===========================================================================
#include<iostream>
using namespace std;
int main(){
int age;
int party;
cout<<"Enter your age: "; cin >>
age;
if(age<=0){
cout<<"Error: Age cannot be
negative or zero.";
}
else if(age<18){
cout<<"You are not eligible
for voting.";
}
else{
cout<<"[1] Democrat\n";
cout<<"[2]
Republican\n";
cout<<"[3] Independent\nEnter
your choice: ";
cin >> party;
if(party<1 || party>3){
cout<<"Error: Invalid choice.\n";
}else{
cout<<"Vote saved successfully.";
}
}
return 0;
}
===================================================================