Using only C++ 1. (10 points) Wednesday, September 17th, is Constitution Day in
ID: 3562397 • Letter: U
Question
Using only C++
1. (10 points) Wednesday, September 17th, is Constitution Day in the U.S.
Look up the Bill of Rights (first ten amendments to the U.S. Constitution) and
write a program to ask the user for a number (1 to 10) and print out a
brief description of that amendment. A sample run should look like this:
Which amendment? 1
Amendment 1 guarantees freedom of religion, speech, press, assembly, and
petition.
Which amendment? 77
That is not a valid input. Please enter a number between 1 and 10.
Which amendment? 7
Amendment 7 guarantees trial by jury.
Do not use vectors in this program. Name your program hw2pr1.cpp.
2. (20 points) Rewrite problem 1 to use a vector to store the answers, so
that answers[i] contains the answer for the ith amendment. Name your program
hw2pr2.cpp.
Explanation / Answer
#include <iostream>
#include <vector>
//using namespace std;
int main() {
int n;
cout<<"Which amendment?";
cin>>n;
while(1){
while (n<1||n>10)
{
cout<<"That is not a valid input. Please enter a number between 1 and 10 ";
cout<<"Which amendment?";
cin>>n;
}
if(n==1)
{
cout<<"Amendment 1 guarantees Freedom of Speech, Press, Religion and Petition ";
}
if(n==2)
{
cout<<"Amendment 2 guarantees Right to keep and bear arms ";
}
if(n==3)
{
cout<<"Amendment 3 guarantees Conditions for quarters of soldiers ";
}
if(n==4)
{
cout<<"Amendment 4 guarantees Right of search and seizure regulated ";
}
if(n==5)
{
cout<<"Amendment 5 guarantees Provisons concerning prosecution ";
}
if(n==6)
{
cout<<"Amendment 6 guarantees Right to a speedy trial, witnesses, etc ";
}
if(n==7)
{
cout<<"Amendment 7 guarantees Right to a trial by jury ";
}
if(n==8)
{
cout<<"Amendment 8 guarantees Excessive bail, cruel punishment ";
}
if(n==9)
{
cout<<"Amendment 9 guarantees Rule of construction of Constitution ";
}
if(n==10)
{
cout<<"Amendment 10 guarantees Rights of the States under Constitution ";
}
cout<<"Which amendment?";
cin>>n;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.