FloatCalculations - public static void main (String args) {...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // FloatCalculations.java Author: Lewis and Loftus // // Solution to Programming Project 2.3 //******************************************************************** / import java.util.Scanner; i class FloatCalculations { //----------------------------------------------------------------- // Reads two floating point numbers and prints their sum, // difference, and product. //-----------------------------------------------------------------
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public static void main (String args) { float num1, num2; Scanner sc = new Scanner (System.in); System.out.print ("Enter the first number: "); num1 = Float.parseFloat(sc.nextLine()); System.out.print ("Enter the second number: "); num2 = Float.parseFloat(sc.nextLine()); System.out.println ("Their sum is: " + (num1+num2)); System.out.println ("Their difference is: " + (num1-num2)); System.out.println ("Their product is: " + (num1*num2)); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online