Reference no: EM13940711
Please explain the errors in the following Java code.
// AverageAndSmallest
// This program will get three numbers from the user
// and determine the smallest number and the average
import java.util.Scanner; // Scanner class used for getting user input
public class AverageAndSmallest
{
// The main method that begins execution of Java application
public static void main(String args[])
{
// variable declarations
int num1; // first number to compare
int num2; // second number to compare
int num3; // third number to compare
int smallest = 0; // variable to hold smallest
double average; // variable to hold average
// create Scanner to capture input from console
Scanner input = new Scanner(System.in);
// get user input, num1 and num2
System.out.print("Enter first number: ");
num1 = input.nextInt();
System.out.print("Enter second number: ");
num2 = input.nextInt();
System.out.print("Enter third number: ");
num3 = input.nextInt();
// Compare and determine the smallest
if (num1 > num2)
smallest = num2;
if (num1 < num2)
smallest = num1;
if (num3 < smallest)
smallest = num3;
// Calculate the average
average = num1 + num2 + num3 / 3;
// Display average and the smallest
System.out.printf("Average is %.2fn", average);
System.out.printf("Smallest is %dn", smallest);
}
}
Explain the purpose of tqm
: Define and explain the purpose of TQM. What elements within a manufacturing environment need to be reduced or eliminated as part of a Lean Manufacturing focus?
|
Risk management program for an organisation
: This project entails you planning, conducting and evaluating a risk management program for an organisation. For the purpose of this project, the term organisation can include a small business, work team or division in a large organisation, sportin..
|
What fundamental assumptions of career criminal programs
: What are some of the fundamental assumptions of career criminal programs? What limitations might these assumptions present in our efforts to identify and punish career criminals?
|
What is the slope of the cal
: Draw the CAL of your portfolio on an expected return-standard deviation diagram. What is the slope of the CAL? Show the position of your client on your funds CAL
|
Compare and determine the smallest number
: The main method that begins execution of Java application
|
Determine human resources requirements
: Determine human resources requirements. Analyze the strategic and operational plans to determine human resource requirements and develop options for the delivery of human resource services.
|
Create a simple 2d predator-prey simulation.
: The goal for this programming project is to create a simple 2D predator-prey simulation. In this simulation the prey are ants and the predators are doodlebugs. These critters live in a world composed of a 20x20 grid of cells.
|
What is ethical for the superintendent to do
: Is it ethically justifiable to disregard the minor crime of prostitution if it is believed that it will assist in capturing more dangerous or violent criminals? Use relative statements and arguments to support your stand.
|
Calculate the vertical height raised
: Calculate the vertical height raised, the final angular velocity of the drum, the work done, the input torque to the driving motor and the average power developed.
|