You are on page 1of 16

Rose Mae D.

Cales
ICT 1 - 1

Activity 5

2. Write a program that will input a number and will print “DIVISIBLE” if the input number is
divisible by 5, otherwise print “NOT DIVISIBLE”
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int n;

cout<<"\n\t\tDivisilbe or Not Divible by 5"<<endl;


cout<<"\n\tInput a number: ";
cin>>n;

if (n%5==0){
cout<<"\tDIVISIBLE"<<endl;
}
else{
cout<<"\tNOT DIVISIBLE"<<endl;
}

cout<<"\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";

return 0;
}
3. Write a program that will input numbers from 1 to 12 and will display the equivalent months of
the year.

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int n;

cout<<"\n\t\tEquivalent Number of the Months in a Year"<<endl;


cout<<"\n\tInput a number from 1-12: ";
cin>>n;

if (n==1){
cout<<"\tIts equivalent month is JANUARY";
}
else if(n==2){
cout<<"\tIts equivalent month is FEBRUARY";
}
else if(n==3){
cout<<"\tIts equivalent month is MARCH";
}
else if(n==4){
cout<<"\tIts equivalent month is APRIL";
}
else if(n==5){
cout<<"\tIts equivalent month is MAY";
}
else if(n==6){
cout<<"\tIts equivalent month is JUNE";
}
else if(n==7){
cout<<"\tIts equivalent month is JULY";
}
else if(n==8){
cout<<"\tIts equivalent month is AUGUST";
}
else if(n==9){
cout<<"\tIts equivalent month is SEPTEMBER";
}
else if(n==10){
cout<<"\tIts equivalent month is OCTOBER";
}
else if(n==11){
cout<<"\tIts equivalent month is NOVEMBER";
}
else if(n==12){
cout<<"\tIts equivalent month is DECEMBER";
}
else {
cout<<"\n\tERROR";
}

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";

return 0;
}
4. Write a program that checks the value of a variable called temperature. Then display the
following messages depending on the value assigned to the temperature variable.
Temperature Remarks
Less than zero ICE
Between 0 and 100 WATER
Exceeds 100 STEAM
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int t;

cout<<"\n\tEnter Temperature: ";


cin>>t;

if (t<0){
cout<<"\tICE";
}
else if (t<=100){
cout<<"\tWATER";
}
else {
cout<<"\tSTEAM";
}

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";
return 0;
}
6. Write a program that will determine if the input number is ODD or EVEN. Display also the
word ODD if the number is odd, EVEN if the number is even.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int n;

cout<<"\n\t\tIs it Odd or is it Even?"<<endl;


cout<<"\n\tInput a number: ";
cin>>n;

if (n%2==0){
cout<<"\tEVEN";
}
else {
cout<<"\tODD";
}

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";
return 0;
}
7. Write a program that will ask the user to input the age. If the age is less than 18 then display
the message “YOU ARE NOT QUALIFIED TO VOTE”. If the age is 19 and above then display
the message “YOU ARE QUALIFIED TO VOTE”.
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int n;

cout<<"\n\t\tAre You Qualified to Vote?"<<endl;


cout<<"\n\tInput your age: ";
cin>>n;

if (n<18){
cout<<"\n\tYOU ARE NOT QUALIFIED TO VOTE";
}
else {
cout<<"\n\tYOU ARE QUALIFIED TO VOTE";
}

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";

return 0;
}
8. Create a program that displays the total amount of money a company owes for a seminar.
The seminar per person is based on the number of people the company registers. For example,
if the company registers seven people, then the total amount owed by the company is P2800. If
the user enters the number 0 or a negative number, the program should display an appropriate
error message.

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int nr, feePerPerson, total;

cout<<"\n\t\tTthe Total Amount of Money A Company Owes"<<endl;


cout<<"\n\tEnter the number of registrants: ";
cin>>nr;

if (nr<=0){
cout<<"\n\tError";
}
else if (nr>=1 && nr<=4){
feePerPerson=500;
}
else if (nr>=5 && nr<=10){
feePerPerson=400;
}
else {
feePerPerson=300;
}

total=nr*feePerPerson;
cout<<"\n\tTotal amount Owed: "<<total;

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";

return 0;
}
9. Switch Statement program: Displaying a price. A program needs to display a price based on
a product ID entered by the user. The valid product ID and their prices are shown below:
Product ID Price
1 50.55
2 12.35
5 11.46
7 11.46
9 12.35
11 11.46

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

int pi;

cout<<"\n\t\tPrice of the Product ID"<<endl;


cout<<"\n\tChoices for product IDs are 1, 2, 5, 7, 9, 11"<<endl;
cout<<"\n\tEnter product ID: ";
cin>>pi;

switch(pi)
{
case 1:
cout<<"\tPrice: 50.55Php";
break;
case 2:
cout<<"\tPrice: 12.35Php";
break;
case 5:
cout<<"\tPrice: 11.46Php";
break;
case 7:
cout<<"\tPrice: 11.46Php";
break;
case 9:
cout<<"\tPrice: 12.35Php";
break;
case 11:
cout<<"\tPrice: 11.46Php";
break;
default:
cout<<"\tCannot be found...";
}
cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";

return 0;
}
10. Write a program that will convert and display the Letter grade to its equivalent message.
Assign an appropriate error message if the input letter is not from A to F.
Letter grade Message
A EXCELLENT
B ABOVE AVERAGE
C AVERAGE
D BELOW AVERAGE
F FAILED

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input
loop */

int main(int argc, char** argv) {

char l;

cout<<"\n\t\tLetter Grade Message"<<endl;


cout<<"\n\tInput letter: ";
cin>>l;

if ((l=='A')||(l=='a')){
cout<<"\tEXCELLENT";
}
else if ((l=='B')||(l=='b')){
cout<<"\tABOVE AVERAGE";
}
else if ((l=='C')||(l=='c')){
cout<<"\tAAVERAGE";
}
else if ((l=='D')||(l=='d')){
cout<<"\tBELOW AVERAGE";
}
else if ((l=='F')||(l=='f')){
cout<<"\tFAILED";
}
else{
cout<<"\tERROR";
}

cout<<"\n\n----------------------------------------------";
cout<<"\n\tProgrammer's Name: Rose Mae D. Cales";
return 0;
}

You might also like