Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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); break

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

What is the growth rate of GDP per capita?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago