📄 Java Code Submission Thread #2
Replies: 97 comments
import java.util.Scanner;
public class SmartDataAnalyzer {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name: ");
String name=sc.nextLine();
System.out.println("Enter your age: ");
byte age=sc.nextByte();
System.out.println("Enter your height in centimeter: ");
float height=sc.nextFloat();
System.out.println("Enter your weight in Kg: ");
float weight=sc.nextFloat();
float hm=height/100;
float bmi=weight/(hm*hm);
System.out.println("Hello "+name);
System.out.println("Height in meters: "+hm);
System.out.println("BMI: "+bmi);
System.out.println("Rounded BMI: "+(int)bmi);
}
} |
public class PrecisionLossDetector {
public static void main(String[] args) {
double val=99.99;
int num=(int) val;
int round= (int) (val +0.5);
System.out.println("Original Number: "+val);
System.out.println("After direct conversion: "+num);
System.out.println("After rounding logic: "+round);
}
} |
import java.util.Scanner;
public class GroceryBillingSystem {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter price of item: ");
float price=sc.nextFloat();
System.out.println("Enter quantity: ");
int quan=sc.nextInt();
System.out.println("Enter Discount: ");
float per=sc.nextFloat();
float total=price*quan;
float dis=total*(per/100);
float fin=total-dis;
System.out.println("Total: "+total);
System.out.println("Discount: "+dis);
System.out.println("Final Amount: "+fin);
System.out.println("Rounded Amount: "+(int)fin);
}
} |
import java.util.Scanner;
public class TimeConverter {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter total Seconds: ");
int total=sc.nextInt();
int hour= total/3600;
int min=(total%3600)/60;
int sec=total%60;
System.out.println("Hours: "+hour);
System.out.println("Minutes: "+min);
System.out.println("Seconds: "+sec);
}
} |
import java.util.Scanner;
public class SalaryCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter your salary: ");
double salary=sc.nextDouble();
double hra=salary * 0.2;
double da=salary * 0.1;
double gross_sal=salary + hra + da;
double tax=gross_sal*0.05;
int round=(int) tax;
System.out.println("HRA: "+hra);
System.out.println("DA: "+da);
System.out.println("Gross Salary: "+gross_sal);
System.out.println("Tax: "+tax);
System.out.println("Rounded Tax: "+round);
}
} |
import java.util.Scanner;
public class MarksAverageTrap {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter marks of three subjects: ");
int marks1=sc.nextInt();
int marks2=sc.nextInt();
int marks3=sc.nextInt();
double avg=(marks1+marks2+marks3)/3;
int davg=(marks1+marks2+marks3)/3;
System.out.println("Correct Average: "+avg);
System.out.println("Wrong Average: "+davg);
}
} |
import java.util.Scanner;
public class DigitalWalletSystem {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Initial balance: ");
double balance= sc.nextDouble();
System.out.println("Enter Expense 1: ");
double exp1=sc.nextDouble();
System.out.println("Enter Expense 2: ");
double exp2=sc.nextDouble();
double remain_balance=balance - exp1 -exp2;
System.out.println("Remaining Balance: "+ remain_balance);
System.out.println("Remaining Balance: "+(int) remain_balance);
if (remain_balance<0){
System.out.println("Warning : Insufficient Balance");
}
}
} |
import java.util.*;
public class HealthMatric {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = sc.nextLine();
System.out.print("Enter Age: ");
int age = sc.nextInt();
System.out.print("Enter Height (in cm): ");
double heightCm = sc.nextDouble();
System.out.print("Enter Weight (in kg): ");
double weight = sc.nextDouble();
double heightM = heightCm / 100;
double bmi = weight / (heightM * heightM);
String status;
if (bmi < 18.5) {
status = "Underweight";
} else if (bmi >= 18.5 && bmi < 24.9) {
status = "Normal weight";
} else if (bmi >= 25 && bmi < 29.9) {
status = "Overweight";
} else {
status = "Obese";
}
System.out.println("- Health Report ---");
System.out.println("Name: " + name);
System.out.println("Age: " + age);
System.out.println("BMI: " + bmi);
System.out.println("Health Status: " + status);
sc.close();
}
} |
public class Conversion {
public static void main(String[] args) {
double value = 99.99;
int direct = (int) value;
double temp = value + 0.5;
int after = (int) temp;
System.out.println("Original value: " + value);
System.out.println("Rounded value (int): " + after);
}
} |
import java.util.Scanner;
public class BillingSystem {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter price of item: ");
double price = sc.nextDouble();
System.out.println("Enter quantity: ");
int quantity = sc.nextInt();
System.out.println("Enter discount (%): ");
double discount = sc.nextDouble();
double total = price * quantity;
double amount = total * discount / 100;
double finalAmount = total - amount;
double temp = finalAmount + 0.5;
int roundedAmount = (int) temp;
System.out.println("BILL DETAILS ");
System.out.println("Total amount: " + total);
System.out.println("Discount amount: " + amount);
System.out.println("Final amount (before rounding): " + finalAmount);
System.out.println("Final amount (rounded): " + roundedAmount);
}
} |
import java.util.Scanner;
public class Time {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter total seconds: ");
int totalSeconds = sc.nextInt();
int hours = totalSeconds / 3600;
int remaining = totalSeconds % 3600;
int minutes = remaining / 60;
int seconds = remaining % 60;
System.out.println(" Time Breakdown ");
System.out.println("Hours: " + hours);
System.out.println("Minutes: " + minutes);
System.out.println("Seconds: " + seconds);
}
} |
import java.util.Scanner;
public class Salary {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter basic salary: ");
double basic = sc.nextDouble();
double hra = basic * 20 / 100;
double da = basic * 10 / 100;
double gross = basic + hra + da;
double tax = gross * 5 / 100;
double temp = tax + 0.5;
int roundedTax = (int) temp;
System.out.println("SALARY DETAILS");
System.out.println("Basic Salary: " + basic);
System.out.println("HRA (20%): " + hra);
System.out.println("DA (10%): " + da);
System.out.println("Gross Salary: " + gross);
System.out.println("Tax (5%): " + tax);
System.out.println("Rounded Tax: " + roundedTax);
}
} |
import java.util.Scanner;
public class Average {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter marks of subject 1: ");
int m1 = sc.nextInt();
System.out.println("Enter marks of subject 2: ");
int m2 = sc.nextInt();
System.out.println("Enter marks of subject 3: ");
int m3 = sc.nextInt();
double correct = (m1 + m2 + m3) / 3.0;
int sum = m1 + m2 + m3;
double wrong=sum / 3;
System.out.println("RESULT ");
System.out.println("Correct Average: " + correct);
System.out.println("Wrong Average: " + wrong);
}
} |
import java.util.Scanner;
public class Expense {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter initial balance: ");
double balance = sc.nextDouble();
System.out.println("Enter expense 1: ");
double exp1 = sc.nextDouble();
System.out.println("Enter expense 2: ");
double exp2 = sc.nextDouble();
double remaining = balance - exp1 - exp2;
double temp = remaining + 0.5;
int rounded = (int) temp;
System.out.println("EXPENSE SUMMARY ");
System.out.println("Remaining Balance: " + remaining);
System.out.println("Rounded Balance: " + rounded);
if (remaining < 0) {
System.out.println("Warning: Insufficient balance!");
}
}
} |
public class test {
public static void main(String[] args) {
int num = 10;
int user_age = 25;
int result = 10 + 5 * 2;
System.out.println(+result);
}
} |
|
Name: Debopriya Sett Code: //Problem 25
public class CompoundAssignmentSimulator {
public static void main(String[] args) {
int x = 10;
x += 5;
x *= 3;
x -= 10;
x /= 5;
System.out.println("Final Value: "+x);
}
} |
|
Name: Debopriya Sett Code: // Problem 26
public class MultiStepExpression {
public static void main(String[] args) {
int x = 5;
int y = 10;
int result = x++ + y-- + ++x + --y;
/*
Step 1: x++ = 5 --> x=6
5 + y-- + ++x + --y
Step 2: y-- = 10 --> y=9
5 + 10 + ++x + --y
Step 3: ++x = 6+1 = 7 --> x=7
5 + 10 + 7 + --y
Step 4: --y = 9-1 =8 --> y=8
5 + 10 + 7 + 8 = 30
*/
System.out.println("x: "+x);
System.out.println("y: "+y);
System.out.println("Result: "+result);
}
} |
|
Name: Debopriya Sett Code: //Problem 27
import java.util.Scanner;
public class AverageOfThreeNumbers {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter three numbers: ");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
double average=(a+b+c)/3;
System.out.println("Average: "+average);
}
} |
|
Name: Debopriya Sett Code: //Problem 28
import java.util.Scanner;
public class SecondsConverter {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.println("Enter total Seconds: ");
int total=sc.nextInt();
int min=total/60;
int sec=total%60;
System.out.println("Minutes: "+min);
System.out.println("Seconds: "+sec);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
import java.util.Scanner;
public class TotalMarksPercentage {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m1 = 80, m2 = 70, m3 = 90;
int total = m1 + m2 + m3;
double percentage = (double) total / 300 * 100;
System.out.println("Total: " + total);
System.out.println("Percentage: " + percentage);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
import java.util.Scanner;
public class SimpleInterestCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int P = 1000;
int R = 5;
int T = 2;
double SI = (P * R * T) / 100.0;
System.out.println("Simple Interest: " + (int)SI);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
import java.util.Scanner;
public class RectangleCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length = 10;
int width = 5;
int area = length * width;
int perimeter = 2 * (length + width);
System.out.println("Area: " + area);
System.out.println("Perimeter: " + perimeter);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
import java.util.Scanner;
public class TemperatureConverter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double celsius = 25;
double fahrenheit = (celsius * 9 / 5) + 32;
System.out.println("Fahrenheit: " + fahrenheit);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
import java.util.Scanner;
public class DigitSum {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = 47;
int lastDigit = num % 10;
int firstDigit = num / 10;
int sum = firstDigit + lastDigit;
System.out.println("Sum of digits: " + sum);
}
}
|
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class CompoundAssignmentSimulator {
public static void main(String[] args) {
int x = 10;
x += 5; // x = x + 5
x *= 3; // x = x * 3
x -= 10; // x = x - 10
x /= 5; // x = x / 5
System.out.println("Final Value: " + x);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class AverageOf3Numbers {
public static void main(String[] args) {
int a = 10, b = 20, c = 30;
double average = (a + b + c) / 3.0;
System.out.println("Average: " + average);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class SecondsConverter {
public static void main(String[] args) {
int totalSeconds = 125;
int minutes = totalSeconds / 60;
int seconds = totalSeconds % 60;
System.out.println("Minutes: " + minutes);
System.out.println("Seconds: " + seconds);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class IncrementBehaviorTracker {
public static void main(String[] args) {
int x = 5;
int result = x++ + ++x;
System.out.println("Final x: " + x);
System.out.println("Result: " + result);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class ExpressionEvaluator {
public static void main(String[] args) {
int a = 10, b = 5, c = 2, d = 20, e = 5;
int result = a + b * c - d / e;
System.out.println("Result: " + result);
}
} |
|
Name: Bipasha Mal Code: package com.bipasha.basics;
public class MultiStepExpression {
public static void main(String[] args) {
int x = 5;
int y = 10;
int result = x++ + y-- + ++x + --y;
System.out.println("x: " + x);
System.out.println("y: " + y);
System.out.println("result: " + result);
}
} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Welcome to the Java Code Submission Thread 🎯
Please submit your solution by following the format below:
✅ Submission Guidelines
.javafile📂 Submission Format
Name:
File Name:
Code:
// Paste your complete .java code here🧩 Example Submission
Name: Soumyajit Nandi
File Name: PalindromeChecker.java
Code:
Happy Coding 💻🔥
All reactions