Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- void showInfo()
- {
- cout << "Hi, Andrew! This should be my personal information for the lecturer to see, lol\n";
- }
- void Q1()
- {
- int EquationChoice;
- double s,u,t,a;
- do
- {
- cout << "\nEquation of motion - SUAT\n"
- << "1. Find s\n"
- << "2. Find a\n"
- << "3. Return to main menu\n"
- << "Option: ";
- cin >> EquationChoice;
- switch (EquationChoice)
- {
- case 1:
- cout <<"Input the vale of u: ";
- cin >> u;
- cout <<"Input the vale of t: ";
- cin >> t;
- cout <<"Input the vale of a: ";
- cin >> a;
- s = u*t+ 0.5*a*t*t;
- cout << "The value of s is " << fixed << setprecision(3) << s << " units\n";
- break;
- case 2:
- cout <<"Input the vale of u: ";
- cin >> u;
- cout <<"Input the vale of t: ";
- cin >> t;
- cout <<"Input the vale of s: ";
- cin >> s;
- a = (2*(s-u*t))/(t*t);
- cout << "The value of a is " << fixed << setprecision(3) << a << " units\n";
- break;
- case 3:
- cout << "Goodbye!!";
- break;
- default:
- cout <<"Please enter choice 1 - 3 only.\n";
- }
- }while (EquationChoice!=3);
- }
- void Q2()
- {
- int number, SmallestEven=0, LargestOdd=0;
- do{
- cout << "Please input an integer: ";
- cin >>number;
- if (SmallestEven==0 || LargestOdd ==0)
- {
- if (number%2 ==0)
- SmallestEven=number;
- else
- LargestOdd=number;
- }
- else
- {
- if (number%2 ==0){
- if(number<SmallestEven && number>0)
- SmallestEven=number;}
- else{
- if(number>LargestOdd)
- LargestOdd=number;}
- }
- }while(number>0);
- cout << "The smallest even number of all your input integers is " << SmallestEven << endl;
- cout << "The largest odd number of all your input integers is " << LargestOdd << endl;
- cout << "\nMultiples:\n";
- int i,j,k;
- for(i=0;i<=40;i+=10){
- for(j=1;j<=10;j++){
- cout << setw(3) << right << i+j;
- if((i+j)%10==0)
- cout << endl;}
- for(k=1;k<=10;k++){
- if ((k+i)%SmallestEven==0 && (k+i)%LargestOdd==0)
- {
- cout << setw(3) << right << "&";
- }
- else if ((k+i)%SmallestEven==0)
- cout << setw(3) << right << "B";
- else if ((k+i)%LargestOdd==0)
- cout << setw(3) << right << "A";
- else
- cout << setw(3) << right << " ";
- if((i+k)%10==0)
- cout << endl << endl;
- }
- }
- }
- void Q3()
- {
- }
- int main(){
- int prog_choice;
- showInfo();
- do {
- cout << endl;
- cout << "Assignment One - Program Selection Menu" << endl;
- cout << "---------------------------------------" << endl;
- cout << "Enter the program choice: ";
- cin >> prog_choice;
- switch (prog_choice){
- case 1: Q1(); break;
- case 2: Q2(); break;
- case 3: Q3(); break;
- case 4: break;
- default:
- cout << "Please enter option 1 - 4 only." << endl;
- break;
- }
- } while (prog_choice != 4);
- cout << "Program terminates. Good bye!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement