Answer to Question #215146 in Java | JSP | JSF for Asad

Question #215146
There is an android distance converter application , that inputs distance (ie. in feet or yards ) and facilitates user to convert into yards or feet You are required to write only java code to develop this application Sample of the application is given below. [10 Marks Following are formulas given for caluclations . Yards to Feet = input Feet to Yards = input 3
1
Expert's answer
2021-07-08T09:42:53-0400
import java.util.Scanner;


public class YardsToFeetConverter {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		Scanner input = new Scanner(System.in);
		String name = "";
		int value = 0;
		int result = 0;
		String tryng = "";
		do {
			System.out.println("Please provide value and press Enter: ");
			value = input.nextInt();
			System.out.println("Please provide f- Feet or y if Yard and press Enter: ");
			name = scan.nextLine();


			if (name.equals("y")) {
				result = value * 3;
				System.out.println("Entered value of Yards are eqals: " + result + " Feet");
			} else if (name.equals("f")) {
				result = value / 3;
				System.out.println("Entered value of Feet are eqals: " + result + " Yards");
			}
			System.out.println("One more? If Yes provide y of No provide n and press Enter: ");
			tryng=scan.nextLine();
		} while (!tryng.equals("n"));
		scan.close();
		input.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS