CODE
CODE
IN COMP2 &
COMP3
Submitted by:
Alonsagay, Jeffrey Ryan
Abude, Floriza
Linatoc, Geneva
Loyola, Hanna Fey
(CED-01-401A)
Submitted to:
Dr. Arlene Grace Diaz
1. Write a program that would input a password and test if the password
entered is correct and display the “Password Accepted!!!” otherwise display
“Invalid Password!!!”, if an incorrect password is entered three times, the
message “Account is Blocked!!!” will appear.
CODE:
#include<iostream.h>
// c++ program that will input password and test whether if it is correct or
incorrect.
int main()
{
// declaration of variables
int pass, ctr=1;
}
cout<<"\n\n\t\t\tAccount is Blocked!!!";
return 0;
}
SCREENSHOT:
2. Write a program that would input the following data: Student Name,
Average, Tuition Fee and print the Total Tuition Fee where
Average Discount
95-100 100%
90-94 50%
85-89 25%
84-below 0
CODE:
#include<iostream.h>
// c++ program that will input the student name, average, tuition fee and print
the total tuition fee.
int main()
{
// declaration of variables
char name [100];
int ave, tuition, totalfee, discount;
// if-else condition
if(ave>=95 && ave<=100){
discount = tuition *.100;
totalfee = tuition - discount;
cout<<"\n\n\t\t\tYour Total Tuition Fee is: "<<totalfee;
} else {
discount = tuition *.0;
totalfee = tuition - discount;
cout<<"\n\n\t\t\tYour Total Tuition Fee is: "<<totalfee;
return 0;
}
SCREENSHOT:
3. Write a program that would accept two numbers and a character based
on the selection below, otherwise display “Invalid Input!!!” and ask the user
to try again. After accepting the character, the program will perform the
specified arithmetic operation and the answer will be displayed.
Sample output:
First Number: 7
Second Number: 7
<+> Addition
<-> Subtraction
<*> Multiplication
</> Division
Enter choice: *
The answer is 28
CODE:
#include<iostream.h>
// c++ program that will accept two numbers and make the user choose the
arithmetic operation.
int main()
{
// declaration of variables
int num1, num2;
char operation;
cout<<"\n\n\t\tEnter first number: ";
cin>>num1;
cout<<"\n\t\tEnter second number: ";
cin>>num2;
cout<<"\n\n\t\tPlease choose an operation.";
cout<<"\n\n\t\t<+> Addition";
cout<<"\n\t\t<-> Subtraction";
cout<<"\n\t\t<*> Multiplication";
cout<<"\n\t\t</> Division";
cout<<"\n\n\t\tEnter choice: ";
cin>>operation;
// switch
switch(operation)
{
case '+': cout<<"\n\n\t\tThe Answer is: "<<num1+num2;break;
case '-': cout<<"\n\n\t\tThe Answer is:"<<num1-num2;break;
case '*': cout<<"\n\n\t\tThe Answer is:"<<num1*num2;break;
case '/': cout<<"\n\n\t\tThe Answer is:"<<num1/num2;break;
default: cout<<"\n\n\t\tInvalid Input! Please Try Again.";
}
return 0;
}
SCREENSHOT: