From 5037b04af733d4d54fa057f8cc12f6dbb61145a4 Mon Sep 17 00:00:00 2001 From: "Dr. BHASKAR MARAPELLI" <34471404+bhaskarmarapelli@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:59:15 +0530 Subject: [PATCH 1/4] Add files via upload --- MyClass.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 MyClass.java diff --git a/MyClass.java b/MyClass.java new file mode 100644 index 0000000..6e62192 --- /dev/null +++ b/MyClass.java @@ -0,0 +1,13 @@ +class MyClass { + public static void main(String[] args) { + int x, y, sum; + + x = 100 + + + y = 200 + + sum = x + y; // Calculate the sum of x + y + System.out.println("Sum is: " + sum); // Print the sum + } +} \ No newline at end of file From efadd3c423b1608b62b173ff48a390d529cfcb76 Mon Sep 17 00:00:00 2001 From: "Dr. BHASKAR MARAPELLI" <34471404+bhaskarmarapelli@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:01:44 +0530 Subject: [PATCH 2/4] Update MyClass.java --- MyClass.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MyClass.java b/MyClass.java index 6e62192..530750c 100644 --- a/MyClass.java +++ b/MyClass.java @@ -2,12 +2,12 @@ class MyClass { public static void main(String[] args) { int x, y, sum; - x = 100 + x = 100; - y = 200 + y = 200; sum = x + y; // Calculate the sum of x + y System.out.println("Sum is: " + sum); // Print the sum } -} \ No newline at end of file +} From 98487f2b31015475911bb857780a3fb81835e470 Mon Sep 17 00:00:00 2001 From: "Dr. BHASKAR MARAPELLI" <34471404+bhaskarmarapelli@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:03:19 +0530 Subject: [PATCH 3/4] Update MyClass.java --- MyClass.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/MyClass.java b/MyClass.java index 530750c..8bafeb2 100644 --- a/MyClass.java +++ b/MyClass.java @@ -1,13 +1,16 @@ +import java.util.Scanner; // Import the Scanner class + class MyClass { public static void main(String[] args) { int x, y, sum; - - x = 100; + Scanner myObj = new Scanner(System.in); // Create a Scanner object + System.out.println("Type a number:"); + x = myObj.nextInt(); // Read user input - - y = 200; + System.out.println("Type another number:"); + y = myObj.nextInt(); // Read user input sum = x + y; // Calculate the sum of x + y System.out.println("Sum is: " + sum); // Print the sum } -} +} From 294b5cb6603e4c5b6880a723f44e4a827be68df0 Mon Sep 17 00:00:00 2001 From: "Dr. BHASKAR MARAPELLI" <34471404+bhaskarmarapelli@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:05:50 +0530 Subject: [PATCH 4/4] Update MyClass.java --- MyClass.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MyClass.java b/MyClass.java index 8bafeb2..530750c 100644 --- a/MyClass.java +++ b/MyClass.java @@ -1,16 +1,13 @@ -import java.util.Scanner; // Import the Scanner class - class MyClass { public static void main(String[] args) { int x, y, sum; - Scanner myObj = new Scanner(System.in); // Create a Scanner object - System.out.println("Type a number:"); - x = myObj.nextInt(); // Read user input + + x = 100; - System.out.println("Type another number:"); - y = myObj.nextInt(); // Read user input + + y = 200; sum = x + y; // Calculate the sum of x + y System.out.println("Sum is: " + sum); // Print the sum } -} +}