Answer to Question #213641 in C++ for Khojo

Question #213641

Question1

Write a C++ program for simple voting system.The program should display ELIGIBLE VOTER when age entered is 18 or more.Else the program should display NOT ELIGIBLE VOTER



QUESTION TWO

As an elder brother/sister write a C++ program for your junior siblings to perform some mathematical operations. The program should receive the first name,age and class of your sibling. The program should welcome him or her with the first name when entered together with a message(example;welcome Richard to basic maths program).

The program should allow him or her to perform area of trapezium when age is above 12 and class is class 5 or above. Else he or she should be allowed to perform perimeter of a rectangle.


Note: All inputs must be entered by the user and not assigned by the programmer.







1
Expert's answer
2021-07-05T01:07:58-0400

QUESTION ONE

// A program to test eligibility to vote

#include<iostream>
using namespace std;
int main()
{
	int a;
	
	cout<<"Enter you age: ";
	cin>>a;
	
	if(a>=18)
	{
		cout<<"ELIGIBLE VOTER";	
	}
	else 
	{
		cout<<"NOT ELIGIBLE VOTER";	
	}
}




QUESTION TWO

//A program to test siblings' mathematics

#include<iostream>
using namespace std;
int main()
{
string firstName;
int age, siblingClass,length,width,perimeterOfRectange,a,b,height,areaOfTrapezium;
cout<<"Enter Sibling's first name\n";
getline(cin,firstName);
cout<<"Enter Sibling's age (In numbers)\n";
cin>>age;
cout<<"Enter Sibling's Class (In numbers)\n";
cin>>siblingClass;
cout<<"Welcome "<<firstName <<"to basic math program\n\n";

if((age>12) && (siblingClass==5))
{
 cout<<"You are allowed to perform area of trapezium, enter details as directed bellow\n";
 cout<<"\nEnter value of a (Top parallel side) \n";
 cin>>a;
 cout<<"Enter value of b (bottom parallel side) \n";
 cin>>b;
 cout<<"Enter value of height (Distance between parallel sides) \n";
 cin>>height;
 areaOfTrapezium=0.5*(a+b)*height;
 cout<<"The Area of the trapezium = "<<areaOfTrapezium;
  
}
else
{
	cout<<"You are allowed to perform Perimeter of the triangle, enter details as directed bellow\n";
	cout<<"\nEnter value of length\n";
  cin>>length;
  cout<<"Enter value of width\n";
  cin>>width;
  perimeterOfRectange=length*2+width*2;
  cout<<"The Perimeter of the triangle = "<<perimeterOfRectange;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS