Question
CAN SOMEONE PLEASE FIND THE ERROR IN MY JAVA PROGRAM?! import java.util.Scanner; public class question4 { public static void main(String args[]) { Scanner sc=new Scanner(System.in);
CAN SOMEONE PLEASE FIND THE ERROR IN MY JAVA PROGRAM?!
import java.util.Scanner; public class question4 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); double base,height,feet; while(true) { System.out.println("MAIN MENU 1. TRIANGLE PROBLEM 2. FEET2INCHES PROBLEM 3. EXIT"); System.out.println("Enter Your Choice"); int choice=sc.nextInt(); switch(choice) { case 1: TriangleProblem(); break; case 2: Feet2InchesProblem(); break; case 3: break; } } } static void TriangleProblem() { double height,base; Scanner sc=new Scanner(System.in); Triangle triangle=new Triangle(); while(true) { triangle.triangleProblem(); System.out.print("Enter base: "); base=sc.nextDouble(); triangle.setbase(base); System.out.print("Enter height: "); height=sc.nextDouble(); triangle.setHeight(height); System.out.println("Area of Traingle is "+t1.calcArea(base,height)); } } static void Feet2InchesProblem() { double feet; Scanner sc=new Scanner(System.in); Feet2Inches feet2inches=new Feet2inches(); while(true) { feet2inches.feet2inchesProblem(); System.out.print("Enter Feet: "); feet=sc.nextDouble(); feet2inches.setFeet(feet); System.out.print("Feet Converted to Inches: "+feet2inches.calcInches(feet)); } } } } } class Triangle { private double height,width; public double getHeight(){return height;} public void setHeight(double h){height=h;} public double getBase(){return base;} public void setBase(double b){base=b;} public double calcArea(){return (base*height);} } class Feet2Inches { private double feet; public double getfeet(){return feet;} public void setFeet(double f){feet=f;} public double calcInches(){return (feet*12);}
Step 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