Get premium membership and access questions with answers, video lessons as well as revision papers.

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

Next: Discuss the SIX branches of engineering stating brief notes in each.
Previous: Discuss systems engineering under the following: i)Explanation of the term systems engineering. ii)System engineering tools. iii)Models used in systems engineering. iv)Water systems engineering.

View More Computer Science Questions and Answers | Return to Questions Index


Learn High School English on YouTube

Related Questions