CEMIS / [INFS151L]

Lab Work W11

Task I

-Create a C++program that finds the biggest number between three entries.

// Find Biggest

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int A, B, C, Biggest;

cout<"Please Enter the inputs:"<endl;

cin>A>B>C;

Biggest = A;

if(B>Biggest)

Biggest = B;

if(C>Biggest)

Biggest=C;

cout<"The biggest is :"<Biggest<endl;

return 0;

}

Task II

-Create a C++ program that calculates simple interest.

// total & average

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int total, m1, m2, m3, avg;

cout<"Enter input number 1:"<endl;

cin>m1;

cout<"Enter input number 2:"<endl;

cin>m2;

cout<"Enter input number 3:"<endl;

cin>m3;

total = m1 + m2 + m3;

avg = total / 3;

cout<"The total is :"<total<endl;

cout<"The average is :"<avg<endl;

return 0;

}

Task III

-Create a C++ program that displays your GPA in screen.

// Calculate Greades

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int mark;

cout<"Enter your mark"<endl;

cin>mark;

if(mark>90)

cout<"your grade is A"<endl;

return 0;

}

TaskIV

-Create a C++ program that checks if a given number is odd or even.

// Odd & Even numbers

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int number;

cout<"Enter your number"<endl;

cin>number;

if(number % 2 == 0)

cout<"your number is Even"<endl;

else

cout<"your number is Odd"<endl;

return 0;

}

Task V

-Create a C++ program that checks your GPA.

// Calculate Greades

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int mark;

cout<"Enter your mark"<endl;

cin>mark;

if(mark>90 & mark<=100)

cout<"your grade is A"<endl;

if(mark>80 & mark<=90)

cout<"your grade is B"<endl;

if(mark>70 & mark<=80)

cout<"your grade is C"<endl;

if(mark>60 & mark<=70)

cout<"your grade is D"<endl;

if(mark>00 & mark<=60)

cout<"your grade is F"<endl;

return 0;

}

Task VI

Create a C++ program that checks the biggest number among three GPAs.

// BIGGEST GPA

#include <iostream>

#include <string>

using namespace::std;

int main()

{

int GPA1, GPA2, GPA3;

cout<"Enter the GPAs"<endl;

cin>GPA1>GPA2>GPA3;

if(GPA1 > GPA2)

if(GPA1 > GPA3)

cout<"GPA1 is Biggest"<endl;

else

cout<"GPA3 is biggest"<endl;

else if(GPA2 > GPA3)

cout<"GPA2 is biggest"<endl;

else

cout<"GPA3 is biggest"<endl;

return 0;

}

Task VII

Create a C++ program that uses a ternary operation to check if a given number is greater than 15 and then displays the correct execution.

// using ternary operation

#include <iostream>

#include <string>

using namespace std;

int main()

{

int a, b, c;

cout<"Enter the values of a and b"<endl;

cin>a>b;

c = (a<15) ? a : b;

cout<"A = "<a<" b= "<b<" c= "<c<endl;

return 0;

}