Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Then write a driver program to test the method scienceWrite. Finally, write a pr

ID: 3764057 • Letter: T

Question

Then write a driver program to test the method scienceWrite. Finally, write a program that is a sort of super driver program that takes a double value as input and then displays it using the two writeln methods and the scienceWriteln method. Use the number 5 for the number of digits after the decimal point when you need to specify such a number. This super driver program should allow the user to repeat this testing with additional numbers of type double until the user is ready to end the program. This is Programming Project 1 on page 477 of walter savitch java book 7th edition.

Explanation / Answer

import java.text.DecimalFormat;

import java.util.Scanner;

public class Driver {

private static double value;

public static void main(String[] args) {

boolean s=true;

Scanner scan =new Scanner(System.in);

while(s==true) {

System.out.println("Enter a decimal number");

value=scan.nextDouble();

scienceWriteln();

System.out.println("press q to quit.....");

String a=scan.next();

if("q".equalsIgnoreCase(a)) s=false;

}

}

private static void scienceWriteln() {

System.out.println("Decimal value is: "+String.format("%.5f", value));

}

}

output:

Enter a decimal number 23.67

Decimal value is: 23.67000 press q to quit.....

e

Enter a decimal number 26.999999999

Decimal value is: 27.00000 press q to quit.....

q