Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
import java.util.Scanner; | ||
|
||
public class SumOfTheAges { | ||
|
||
public static void main(String[] args) { | ||
Scanner reader = new Scanner(System.in); | ||
|
||
// Implement your program here | ||
System.out.println("Type your name: "); | ||
String name1 = reader.nextLine(); | ||
System.out.println("Type your age: "); | ||
int age1 = Integer.parseInt(reader.nextLine()); | ||
System.out.println("Type your name: "); | ||
String name2 = reader.nextLine(); | ||
System.out.println("Type your age"); | ||
int age2 = Integer.parseInt(reader.nextLine()); | ||
int sumAges = age1 + age2; | ||
System.out.println(name1 + " and " + name2 + " are " + sumAges + " years old in total."); | ||
} | ||
} |