Java #7: How to Intake and Add Numbers

//Programmer:Akinwale Owi
//Progranm Purpose: Ask User For Numbers and Add Them
//Company:Dagba Computers
//——————————————————

//package name
package dagba.computers;

//imports
import java.util.Scanner;

//class name
public class DagbaComputers {

//main function
public static void main(String[] args)
{

//Creation of Scanner
Scanner numScanner = new Scanner (System.in);

//Variables to save user input
double firstNum, secondNum, total;

//Ask User For First Number
System.out.println(“Please enter the first number you want me to add”);

//intake first Number
firstNum = numScanner.nextDouble();

//Print out first number, to check it saved correctly
System.out.println(“The first number is: “+firstNum);

//Space
System.out.println(“”);

//Ask the User For the Second Number
System.out.println(“Please enter the second number:”);

//Space
System.out.println(“”);
//Intake Second Number
secondNum = numScanner.nextDouble();

//Here I print out second number
System.out.println(“The second number is: “+secondNum);

//Space
System.out.println(“”);
//Adding the two numbers
total = firstNum + secondNum;

//printing the total
System.out.println(“The total of two numbers = “+total);

}//End of main function

}//end of DagbaComputers Class

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: