CISS 110 Dialog Box
Need help with this assignment?Get an original answer from a qualified tutor — from $10/page.
Get it written →
5-8. Modify exercise 2-4 where miles per gallon where calculated from the console window. Now modify the program so dialog boxes are used (use all arguments). The prompt and input will be a dialog box instead of a System.out.print() and sc.nextDouble(). The output will be a dialog box instead of a System.out.println(). The input and output will all be the same, but now in dialog boxes. Save as ex58.java and submit it.
* Exercise 2-4
* This program will calculate miles per gallon * */ import java.util.Scanner; public class ex24 { public static void main(String[] args) { double miles, gallons, mpg; // declare variables Scanner sc = new Scanner(System.in); System.out.print("Enter miles: "); // prompt miles = sc.nextDouble(); // input System.out.print("Enter gallons: "); gallons = sc.nextDouble(); mpg = miles / gallons; // calculate System.out.printf("Miles per gallon is %.1fn", mpg); // output } }
Get a plagiarism-free answer to this question
Send us your instructions and we’ll match you with the best writer in your subject.
- 100% human-written, zero AI
- Turnitin report included
- Confidential — we never share your data
- Free revisions & refunds