Question
I am struggling with the JAVA project for weekend assignment. That is what I have for so far. Can someone help me modify and optimization
I am struggling with the JAVA project for weekend assignment.
That is what I have for so far.
Can someone help me modify and optimization my assignment to the following questions?
Use those function to optimize:
1-Try and Catch
2-Overloading
3-Overriding
4-StringBuilder
below is my code:
import java.util.Scanner;
public class Chapter5
{
public static void main(String[] args)
{
System.out.println("This program will calculate your normal weight for you age.");
System.out.println("If you are Female then press 1, Male press 2");
Scanner keyboard0=new Scanner(System.in);
int type=keyboard0.nextInt();
switch(type)
{
case 1:
int FemaleAge;
double FemaleFeet, FemaleInch;
Scanner keyboard=new Scanner(System.in);
System.out.println("Please enter your age: ");
FemaleAge=keyboard.nextInt();
System.out.println("Then enter your feet: ");
FemaleFeet=keyboard.nextDouble();
System.out.println("Then enter your inch: ");
FemaleInch=keyboard.nextDouble();
double FemaleHeight = ((FemaleFeet * 12) + FemaleInch) - 60;
double FemaleWeight=(100 + (FemaleHeight * 5));
System.out.println("Your normal weight for you age is: " +FemaleWeight);
break;
case 2:
int MaleAge;
double MaleFeet, MaleInch;
Scanner keyboard1=new Scanner(System.in);
System.out.println("Please enter your age: ");
MaleAge=keyboard1.nextInt();
System.out.println("Then enter your feet: ");
MaleFeet=keyboard1.nextDouble();
System.out.println("Then enter your inch: ");
MaleInch=keyboard1.nextDouble();
double MaleHeight = ((MaleFeet * 12) + MaleInch) - 60;
double MaleWeight=(106 + (MaleHeight * 6));
System.out.println("Your normal weight for you age is: " +MaleWeight);
break;
}
}
}
import java.util.scanner: public class Chapter5 public static void main(String[] args) System.out.println("This program will calculate your normal weight for you age.") System.out.println("If you are Female then press 1, Male press 2"); Scanner keyboarde-new Scanner (System.in); int type-keyboarde.nextInt); switch(type) case 1: int FemaleAge; double FemaleFeet, FemaleInch; Scanner keyboard=new Scanner(System.in); System.out.println( "Please enter your age: FemaleAge-keyboard.nextInt(); "); System.out.println("Then enter your feet: "); FemaleFeet keyboard.nextDouble(); System.out.println("Then enter your inch:"); FemaleInch-keyboard.nextDouble); ((FemaleFeet * double FemaleHeight 12) + Female!nch) -60; double Femaleweight-(100 (FemaleHeight *5)); System.out.println( "Your normal weight for you age is: "+Femaleweight); breakStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started