Adding Two Doubles

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   hear noise   go to next page

Answer:

What is the meaning of 7.0E-2 ?

The "E-2" part means 10-2 which is 0.01, so the complete expression means 0.07

Adding Two Doubles

Here is the start on a program that asks the user for two doubles, adds them together, and writes out the result.

import java.io.*; import java.util.Scanner; class AddDoubles { public static void main (String[] args) { double first, second, sum; Scanner scan = new Scanner( System.in ); // Read in the first double System.out.print("Enter the first double:"); first = scan.nextDouble(); // Read in the second double // Compute the sum and write it out } }

Fill the blanks to complete the program. (Do this by clicking in a blank and typing. Nothing special happens when you fill the blanks They are just there to give you a place to type.)

QUESTION 6:

Fill in the blanks.