Question

In: Computer Science

(Use C++ language) CREATE A PROGRAM CALLED and or not.cpp THAT: ASKS USER FOR AGE Note:...

(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

Solutions

Expert Solution

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;
}
===================================================================


Related Solutions

C language <stdio.h> use double and const Write a program that asks the user for the...
C language <stdio.h> use double and const Write a program that asks the user for the radius of a circle (as a double) and displays the diameter, circumference, and area of the circle. Use a constant of 3.14159 as the value of pi. Have a blank line between the input and the output. Follow the 3 steps in the Information Processing Cycle - Input, Processing, and Output. The formulas needed are: diameter = 2 * radius circumference = 2 *...
Use c# Create a program called ResortPrices that prompts the user to enter the number of...
Use c# Create a program called ResortPrices that prompts the user to enter the number of days for a resort stay. Then display the price per night and the total price. Nightly rates are R 500.00 for one or two nights, R 650.00 for three or four nights, R 850.00 for five, six or seven nights, and R 1500.00 for eight nights or more.
Using C++ Create a program that asks the user to input a string value and then...
Using C++ Create a program that asks the user to input a string value and then outputs the string in the Pig Latin form. - If the string begins with a vowel, add the string "-way" at the end of the string. For “eye”, it will be “eye-way”. - If the string does not begin with a vowel, first add "-" at the end of the string. Then rotate the string one character at a time; that is, move the...
Create a class called clsTextProcessor.java. Your program should deliver the following: Asks the user for a...
Create a class called clsTextProcessor.java. Your program should deliver the following: Asks the user for a location of a text file, with (FileNotFound) exception handling: Keep asking for a valid file name and location If an invalid file is provided, display an error message. Once provided, proceed. Opens the text file and finds the following: Minimum value Maximum value The average value of all number in the text Prints a message displaying the values in step No. 2
in C++, Write a program that asks the user to enter 6 numbers. Use an array...
in C++, Write a program that asks the user to enter 6 numbers. Use an array to store these numbers. Your program should then count the number of odd numbers, the number of even numbers, the negative, and positive numbers. At the end, your program should display all of these counts. Remember that 0 is neither negative or positive, so if a zero is entered it should not be counted as positive or negative. However, 0 is an even number....
In a file called LengthSum.java, write a program that: - Asks the user to enter a...
In a file called LengthSum.java, write a program that: - Asks the user to enter a string. - Asks the user to enter a second string. - Prints out the length of the first string, the length of the second string, and the sum of the two lengths, using EXACTLY the same format as shown below. For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this: Please enter a string: UT Please...
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to...
Create a basic program (C programming language) that accomplishes the following requirements: Allows the user to input 2 numbers, a starting number x and ending number y Implements a while loop that counts from x (start) to y(end). Inside the loop, print to the screen the current number Print rather the current number is even or odd If the number is even , multiply by the number by 3 and print the results to the screen. If the number is...
Create a program that asks the user for the names of two car dealerships and the...
Create a program that asks the user for the names of two car dealerships and the # of cars sold in each one. Then output that data in two columns as shown below. The "Store location" column has a width of 25, while the "Cars sold" column has a width of 9. Also, notice the alignment of the second column. The program should end with the "Press Enter to end this program" prompt. OUTPUT Enter the location for the first...
Q1 Create a program that asks the user to input their budget. Then, it will ask...
Q1 Create a program that asks the user to input their budget. Then, it will ask the user to input each of their purchase until their entire budget is used up. What kind of loop do you think is the most appropriate? You don't have to create the entire program. Part of it has already been created for you (see code below). Note: Assume that the user always uses up their budget to the last cent and they don't over...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT