From 196ddfd02a874cd9fd87a8eebbb9d4dbb48475f9 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Sun, 12 Oct 2025 09:45:42 +0000 Subject: [PATCH 1/4] Setting up GitHub Classroom Feedback From d983801593b85fe301cefa5c5b9ea55982b8fdd0 Mon Sep 17 00:00:00 2001 From: "github-classroom[bot]" <66690702+github-classroom[bot]@users.noreply.github.com> Date: Sun, 12 Oct 2025 09:45:44 +0000 Subject: [PATCH 2/4] add deadline --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 064f0ae..7eb64d3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/ty2f_0nx) # Java-Task1 — Introductory Java Exercises This repository contains three beginner-friendly Java exercises built around the following topics: From a234415fb177fd5b60eb64688cdc7f2be1d1a202 Mon Sep 17 00:00:00 2001 From: Omkar Pardeshi Date: Sun, 12 Oct 2025 15:26:20 +0530 Subject: [PATCH 3/4] Update q1.java --- q1/q1.java | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/q1/q1.java b/q1/q1.java index 17e9650..c844cf2 100644 --- a/q1/q1.java +++ b/q1/q1.java @@ -1,47 +1,62 @@ // FILL HERE: Import the necessary package for input operations - +import java.util.Scanner; // FILL HERE: Write the class declaration with proper naming convention -{ +public class q1 { // FILL HERE: Write the main method signature - { + public static void main(String[] args) { // Variable declarations and initialization // FILL HERE: Declare an integer variable named 'age' and initialize it to 25 + int age = 25; // FILL HERE: Declare a double variable named 'height' and initialize it to 5.8 + double height = 5.8; // FILL HERE: Declare a char variable named 'grade' and initialize it to 'A' + char grade = 'A'; // FILL HERE: Declare a boolean variable named 'isStudent' and initialize it to true + boolean isStudent = true; // FILL HERE: Declare a String variable named 'name' and initialize it to "John Doe" + String name = "John Doe"; // Output statements System.out.println("=== Student Information ==="); // FILL HERE: Print the name using System.out.println + System.out.println("Name: " + name); // FILL HERE: Print the age using System.out.println (format: "Age: 25") + System.out.println("Age: " + age); // FILL HERE: Print the height using System.out.println (format: "Height: 5.8 feet") + System.out.println("Height: " + height + " feet"); // FILL HERE: Print the grade using System.out.println (format: "Grade: A") + System.out.println("Grade: " + grade); // FILL HERE: Print the student status using System.out.println (format: "Is Student: true") + System.out.println("Is Student: " + isStudent); // Data type demonstration System.out.println("\n=== Data Type Information ==="); // FILL HERE: Print the data type of age variable (hint: use "int") + System.out.println("age is of type: int"); // FILL HERE: Print the data type of height variable (hint: use "double") + System.out.println("height is of type: double"); // FILL HERE: Print the data type of grade variable (hint: use "char") + System.out.println("grade is of type: char"); // FILL HERE: Print the data type of isStudent variable (hint: use "boolean") + System.out.println("isStudent is of type: boolean"); // FILL HERE: Print the data type of name variable (hint: use "String") + System.out.println("name is of type: String"); } -} \ No newline at end of file +} From 3e5109a4f63ae66b87bf963001842cacc9ac3b76 Mon Sep 17 00:00:00 2001 From: omkarpardeshi1499 Date: Sun, 12 Oct 2025 16:23:58 +0530 Subject: [PATCH 4/4] completed all three problems --- README.md | 1 - q1/q1.class | Bin 0 -> 1503 bytes q1/q1.java | 2 +- q2/q2.class | Bin 0 -> 3028 bytes q2/q2.java | 75 ++++++++++++++++++++++++++++++++++++------- q3/q3.class | Bin 0 -> 3224 bytes q3/q3.java | 89 +++++++++++++++++++++++----------------------------- 7 files changed, 104 insertions(+), 63 deletions(-) create mode 100644 q1/q1.class create mode 100644 q2/q2.class create mode 100644 q3/q3.class diff --git a/README.md b/README.md index 7eb64d3..064f0ae 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/ty2f_0nx) # Java-Task1 — Introductory Java Exercises This repository contains three beginner-friendly Java exercises built around the following topics: diff --git a/q1/q1.class b/q1/q1.class new file mode 100644 index 0000000000000000000000000000000000000000..d3d8f99281862dffe314751fbd8837da7ae53240 GIT binary patch literal 1503 zcmaJ>-BJ@t6#hDd%n$>_AYepvRMbRQBckXMB4Q8;Mszn6TkBpmNt28u-7wR!ic2ru zC)n3mFSIHbK7bG6V_2S^37RaaovAwK^y%;X_UZoet@9bcQ*6f(!H|V$0>g+gB;WA2 zJlEv1o_o3bMpQLJY}u8re#9`8$?n7+PcHwOlFO?%- zixwHHHu;(?2mW1^d*!)OSF|U1D{mvkFjFWLoQiJOgw#$+?kTUuwX38<`Z&&D(!x{% z(>Tj8F~A9fbzodJB}K`EVS+L!hAZp&>`sabK9|4@&NEE6_`WDAS>^f-xtB*6Vp!sixr4#yx7Z^)IR``Y6NFNAKWnr~x;_O~dH zC5PEqrHNjxhjNi&Y$GV2wwyg7s3lKnte=^h1N1Y7(UN~Wm!ukxp%lj^o?9rJlX<}~ z_w&xU@~zqzxv<7?zSenFEANQmpWeyp0>czHxU4mWKUY?2zkQHDS#FP}&(NIq0C;c1 z!dsm09i6U=B5yV;t`>QQL`h2F6`S1mg>T^%!_^Zt4NBF*?=*e?52bd8b>R~3(_>@4 z2;ClfZiqgh)huyFeE7yEuzyKlcu3T2lM*BN6-y)==vNHEBK~(Wy?h2%DY?2BjV=zS zMwVh9a4L2BBPNKaV;!V{a52-N09`rLfpaWRMmxCjV=>&pwc|x98(OArcKNL?&vp5H zmoE_ineQgd3lpadM=8f7PGJILm?G^t`e$*SVlPn06^c|w7JuRvIPSnD?I9L%M0LKy qGTx&=KJw%%LaPFChq|yq9e5Pb#{qp3(6xZBV=IWv@DjhFg7kOOyl@=wbHfP$F5Z$`a8P%7rM0joXLblVt+tG*faZl`|SOlefB;le>^Gw z3g8I738M)C3Bd@O(ZaClvbv-W8>+c5JeR$!=44(AR!XLMzq#>$t*jrR$yq-O@`Qvn5kRCX|q^zGp?Oka#ZK@UUN)ULWItCTe~k(!i@muQ|B+0k;A znXiVH(Z{eYJTWn$OsPh$WT>uXE2lN5WVnt(!<^g85hOSLHtE6*O1RDRV{5R$ZMu@W4^p z{#`uCZVHk}r5Za6U{@4DE}FS$!G1pFH9jSsPB(}zW0XNj=}Wppkw$6NrfIoKo(A%o zl3iA=X|~lPW1Jx|YvoHu$*CFi{K=0 ztmd3yIhusi)CyN9*}*9*PleMqqnp|ZQK4s4QA)vr%3Gx)abf+oCg&M8W?VJ5II9+g zy@YdA$_-4ZKr>d!&S}#+FHq^q?jc_A)SHJb%XM5^EzWB0B`fd9c$augi(c`Vj4DjV z`(&E&%D84UOVJMH^E%HynJI(xKf%rOL^)H+lHZ(Qr*i3hM6#a-{2pt&3Rvbka=CBPa{Yr4C>~509cT|@5 zY3?d|@f-T^JC(_w7{Ff`WC6OKyRnn)#}GS37w#h6qz?A58`#Uf$3AusBkU)-Dj(wj z`x~Q80ZcSWIEb@U!jIAY1gjFHK%ng@u?b3eOKAKTS!W>dl-RC~(Ho7i|CM3aB>M*u zRxkMqWj_^+K4=z8_YzW%v{VpEOV@KJ1)huG8KlNt$1~8{meez-YzqQ7FAD7f-lk_3 zoA41GNbd;wo{*}LIUzM67lhP>Toke(q$T7PAsr!0LVh6RvXCF*bBYtD7+>H^e2vb3 E0X&6iApigX literal 0 HcmV?d00001 diff --git a/q2/q2.java b/q2/q2.java index 5f6c53b..dcb8d40 100644 --- a/q2/q2.java +++ b/q2/q2.java @@ -1,12 +1,63 @@ -// q2.java - Calculator Program -// Write a complete Java program that acts as a simple calculator - -// Your program should: -// 1. Import the Scanner class -// 2. Create a class named 'q2' -// 3. Implement the main method -// 4. Get two numbers from the user -// 5. Perform arithmetic operations and display results -// 6. Demonstrate different types of operators (arithmetic, relational, logical) - -// Write your complete solution below: \ No newline at end of file +// q2.java - Simple Calculator Program + +// Import the Scanner class for user input +import java.util.Scanner; + +// Create a class named q2 +public class q2 { + // Implement the main method + public static void main(String[] args) { + // Create a Scanner object for input + Scanner scanner = new Scanner(System.in); + + // Prompt user for input + System.out.print("Enter first number: "); + double num1 = scanner.nextDouble(); + + System.out.print("Enter second number: "); + double num2 = scanner.nextDouble(); + + // Display header + System.out.println("\n=== Calculator Results ==="); + System.out.println("First Number: " + num1); + System.out.println("Second Number: " + num2); + + // Arithmetic operations + System.out.println("\n=== Arithmetic Operations ==="); + System.out.println("Addition: " + num1 + " + " + num2 + " = " + (num1 + num2)); + System.out.println("Subtraction: " + num1 + " - " + num2 + " = " + (num1 - num2)); + System.out.println("Multiplication: " + num1 + " * " + num2 + " = " + (num1 * num2)); + + // Division with zero-check + if (num2 != 0) { + System.out.println("Division: " + num1 + " / " + num2 + " = " + (num1 / num2)); + System.out.println("Modulus: " + (int)num1 + " % " + (int)num2 + " = " + ((int)num1 % (int)num2)); + } else { + System.out.println("Division: Cannot divide by zero!"); + System.out.println("Modulus: Cannot perform modulus by zero!"); + } + + // Relational operations + System.out.println("\n=== Relational Operations ==="); + System.out.println(num1 + " > " + num2 + ": " + (num1 > num2)); + System.out.println(num1 + " < " + num2 + ": " + (num1 < num2)); + System.out.println(num1 + " >= " + num2 + ": " + (num1 >= num2)); + System.out.println(num1 + " <= " + num2 + ": " + (num1 <= num2)); + System.out.println(num1 + " == " + num2 + ": " + (num1 == num2)); + System.out.println(num1 + " != " + num2 + ": " + (num1 != num2)); + + // Logical operations + System.out.println("\n=== Logical Operations ==="); + boolean greater = (num1 > num2); + boolean notEqual = (num1 != num2); + boolean less = (num1 < num2); + boolean equal = (num1 == num2); + + System.out.println("(" + num1 + " > " + num2 + ") && (" + num1 + " != " + num2 + "): " + (greater && notEqual)); + System.out.println("(" + num1 + " < " + num2 + ") || (" + num1 + " == " + num2 + "): " + (less || equal)); + System.out.println("!(" + num1 + " == " + num2 + "): " + (!equal)); + + // Close scanner + scanner.close(); + } +} diff --git a/q3/q3.class b/q3/q3.class new file mode 100644 index 0000000000000000000000000000000000000000..112b0c04791541cb667f329ba43cd0fe58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