Trusted by millions of Kenyans
Study resources on Kenyaplex

Get ready-made curriculum aligned revision materials

Exam papers, notes, holiday assignments and topical questions – all aligned to the Kenyan curriculum.

Write a java program that allows user to input three numbers and output the largest of the three number after program compilation

Write a java program that allows user to input three numbers and output the largest of the three number after program compilation.

Answers


DUKE
We use Scanner class to create the object that we will take the inputs from the user.

Duemak answered the question on June 2, 2019 at 14:29

Sha
#include
#include
using namespace std;
class largest
{
int num1, num2;
float large;
public:
void getdata();
void displaydata();
void getlargest();
void displaylargest();
};
void largest::getdata()
{
cout<<"enter first number...\n"< cin>>num1;
cout<<"enter the second number...\n"< cin>>num2;
}
void largest::displaydata()
{
cout<<"the first number is...\n"< cout<<"the second number is....\n"<}
void largest::getlargest()
{
if(num1>num2)
{
large=num1;}
else{
large=num2;
}
}
void largest::displaylargest()
{
cout<<"the largest number is...\n"<}

int main()
{
largest largen;
largen.getdata();
largen.displaydata();
largen.getlargest();
largen.displaylargest();
getch ();
}

Totosha answered the question on July 3, 2019 at 13:57

Exams With Marking Schemes

Related Questions