Write a Java program to override method greatest() for finding the greatest of 2 numbers and 3 numbers
Answers
Answer:
Example 1: Finding largest of three numbers using if-else..if
public class JavaExample{
public static void main(String[] args) {
int num1 = 10, num2 = 20, num3 = 7;
if( num1 >= num2 && num1 >= num3)
System.out.println(num1+" is the largest Number");
else if (num2 >= num1 && num2 >= num3)
System.out.println(num2+" is the largest Number");
else
System.out.println(num3+" is the largest Number");
}
}
Output:
20 is the largest Number
Example 2: Program to find largest number among three numbers using nested if
public class JavaExample{
public static void main(String[] args) {
int num1 = 10, num2 = 20, num3 = 7;
if(num1 >= num2) {
if(num1 >= num3)
/* This will only execute if conditions given in both
* the if blocks are true, which means num1 is greater
* than num2 and num3
*/
System.out.println(num1+" is the largest Number");
else
/* This will only execute if the condition in outer if
* is true and condition in inner if is false. which
* means num1 is grater than num2 but less than num3.
* which means num3 is the largest
*/
System.out.println(num3+" is the largest Number");
}
else {
if(num2 >= num3)
/* This will execute if the condition in outer if is false
* and inner if is true which means num3 is greater than num1
* but num2 is greater than num3. That means num2 is largest
*/
System.out.println(num2+" is the largest Number");
else
/* This will execute if the condition in outer if is false
* and inner if is false which means num3 is greater than num1
* and num2. That means num3 is largest
*/
System.out.println(num3+" is the largest Number");
}
}
}
Output:
Explanation:
Answer:
After creating a chart in a worksheet, you can move this chart into other worksheet as you need. In this article, we will show you how to move a specific chart to a new sheet in Excel.
Move a chart to a new sheet in Excel
Office Tab Enable Tabbed Editing and Browsing in Office, and Make Your Work Much Easier...
Read More... Free Download...
Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%
Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
Read More... Free Download...
arrow blue right bubbleMove A Chart To A New Sheet In Excel
Hotexcel-tab-banner-2014-12-02
Amazing! Using Efficient Tabs In Excel Like Chrome, Firefox And Safari!
Save 50% Of Your Time, And Reduce Thousands Of Mouse Clicks For You Every Day!
You can do as follows to move a specific chart to a new sheet in Excel.
1. Select the chart which you want to move to a new sheet.
2. After selecting the chart, the Chart Tools tab is enabled. Please click Design > Move Chart. See screenshot:
3. In the Move Chart dialog box, you need to:
1). If you want to move the chart to a new chart sheet, please check the New sheet option, enter a sheet name and click the OK button;
2). If you just want to move the chart as an object to an existing worksheet of current workbook, please select the Object in option, specify a worksheet in the drop-down list, and finally click the OK button. See screenshot: