java codes
//if else code
package studyopedia;
public class ifff {
public static void main(String[] args) {
int a=20,b=10;
if(a<b) {
System.out.println("smaller value is a" +a);
}else {
System.out.println("smaller value is b" +b);
}
}
//1dollar=100cents write a program to take 2 percens inputs d1,c1 and
d2,c2 and print the total dollars and cents
package user;
public class problem2 {
public static void main(String[] args) {
int d1=10;
int c1=90;
int d2=40;
int c2=20;
int c=c1+c2;
int cents=c%100;
int dol=c/100;
int d=d1+d2+dol;
System.out.println("dollars" +d);
System.out.println("cents "+cents);
//take 3 digit value and using division and modulus reverse the number
package user;
public class prblm {
public static void main(String[] args) {
int a=123;
int b=a%10;
int c=a/10;
int d=c%10;
int e=c/10;
int res=b*100 + d*10 +e;
System.out.println("res is"+res);
}
//details in swiggy
package user;
public class details {
public static void main(String[] args) {
String cust_name = "siri";
float order_total = 55.7f;
byte num = 127;
long phone_no = 1234567879l;
double number = 199.99;
int delivery_time = 30;
boolean status = true;
System.out.println("name is" +cust_name);
System.out.println("order total is" +order_total);
System.out.println("delivery time" +delivery_time);
System.out.println("status is" +status);
System.out.println("phone number is " +phone_no);
System.out.println(" number is " +number);
System.out.println(Byte.MIN_VALUE);
System.out.println(Byte.MAX_VALUE);
System.out.println("byte value" +num);
System.out.println(Integer.MIN_VALUE);
}
//inputs are year and month,need to check whether it is leap year and
print no of days in feb,and remaining no. of days for each month
package studyopedia;
public class problm4 {
public static void main(String[] args[]) {
int y=2012;
int m=1;
if(m==2) {
if(y%4==0 && y%100!=0 || y%400==0) {
System.out.println("No of days 28");
}else {
System.out.println("No of days 29");
}
} else if(m==1 || m==3 || m==5 || m==7 || m==8 || m==10 ||
m==12) {
System.out.println("No of days = 31");
}else {
System.out.println("No of days = 30");
}
1.
import java.util.*;
//
public class Main {
public static void main(String[] args) {
boolean traffic=true;
int del_time=30;
if(traffic==true){
del_time+=10;
System.out.println("increased delivery time is" +del_time);
}else{
System.out.println("no change in dlivery time");
}
}
//9 Session
//Exercise 1.
import java.util.*;
public class Main {
public static void main(String[] args) {
int burger=150;
int fries=80;
int amount=burger+fries;
if(amount>200){
int total= amount - amount*10/100;
System.out.println("total amount is" +total);
}else{
System.out.println("amount is "+amount);
}
}
}
//9 session
//Exercise 2.Tracking Delivery Partner Orders
import java.util.*;
public class Main {
public static void main(String[] args) {
int orders=2;
orders++;
System.out.println("enter whether the order is delivered or not");
Scanner sc=new Scanner(System.in);
boolean delivered=sc.nextBoolean();
if(delivered==true){
orders--;
}
System.out.println("No of remaining orders" +orders);
}
}
//session 9
//exercise 3
import java.util.*;
public class Main {
public static void main(String[] args) {
int order=550;
String rest_name="Bistro Restaurant";
boolean ptnr_rest=true;//assuming given is a partner rest:)
if(order>500 && ptnr_rest){
System.out.println("customer qualifies for the offer");
}else{
System.out.println("customer is not qualified for the offer");
}
}
}
//session 9
//exercise 4
import java.util.*;
public class Main {
public static void main(String[] args) {
int del_time=30;
Scanner sc=new Scanner(System.in);
boolean traffic=sc.nextBoolean();
if(traffic==true){
del_time+=15;
}
System.out.println("Updated delivery time is" +del_time);
}
}
//practice Exercise1:Applyig Service Charge
import java.util.*;
public class Main {
public static void main(String[] args) {
int total_cost=600;
float charges=total_cost*5/100;
float final_amount=total_cost+charges;
System.out.println("final amount is" +final_amount);
}
}
//Practice exercise2 : Discount eligibility for New Users
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
boolean isNewUser=sc.nextBoolean();
double orderValue=sc.nextDouble();
if(isNewUser==true && orderValue>300){
System.out.println("user is eligible for special discount");
}
}
}
//Practic Exercise 3: Calculating Tips
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int orderAmount=sc.nextInt();
float tip;
if(orderAmount<500){
tip=orderAmount * 10/100;
}else{
tip=orderAmount * 15/100;
}
System.out.println(tip);
}
}
//Practice Exercise 4:Updating Total Orders Based on customer Feedback
import java.util.*;
public class Main {
public static void main(String[] args) {
int order_count=3;
Scanner sc=new Scanner(System.in);
int feedback=sc.nextInt();
if(feedback>=3){
System.out.println("Order count remains same" +order_count);
}else{
order_count--;
System.out.println("Order count decreases by one i.e,"
+order_count);
}
}
}
//Practice Exercise 5: Adjustin Delivery Estimates for Weather Conditions
import java.util.*;
public class Main {
public static void main(String[] args) {
int del_time=30;
Scanner sc=new Scanner(System.in);
Boolean isRaining=sc.nextBoolean();
if(isRaining==true){
del_time+=20;
}
System.out.println("Delivery Time" +del_time);
}
}
//Session 10
//exercise 1:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("enter the input");
Scanner sc=new Scanner(System.in);
int amount=sc.nextInt();
double total;
if(amount>1000){
total=amount-(amount*0.2);
System.out.println("output" +total);
}else if(amount>500 && amount<1000) {
total = amount-(amount*0.1);
System.out.println("output " +total);
}else{
System.out.println("no discount is applied and output is"
+amount);
}
}
//Session 10
//Exercise 2
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int distance=sc.nextInt();
int charge;
if(distance>10){
charge=100;
System.out.println("Delivery charge : "+charge);
}else if(distance>5 && distance<10){
charge=50;
System.out.println("Delivery charge : "+charge);
}else{
System.out.println("Free Delivery");
}
}
}
//session 10
//Exercise 3(Doubt)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int time=sc.nextInt();
if(time >= 18 && time <= 21){
System.out.println("15% discount applied");
}else if(time >= 24 && time <= 18){
System.out.println("10% discount applied");
}else{
System.out.println("No discount applied");
}
}
}
//session10
//practice1
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int order=sc.nextInt();
float pay;
if(order>500){
pay=order-order*10/100;
}else if(order>300 && order<500){
pay=order-order*5/100;
}else{
pay=order;
}
System.out.println("final payable amount is "+pay);
}
}
//session10
//practice 2
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int distance=sc.nextInt();
int charge;
if(distance<3){
charge=20;
System.out.println("Delivery charge : "+charge);
}else if(distance>3 && distance<6){
charge=40;
System.out.println("Delivery charge : "+charge);
}else{
charge=60;
System.out.println("Delivery charge : "+charge);
}
}
}
//Session 10
//Practice 3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int time=sc.nextInt();
if(time<11){
System.out.println("Morning Delivery");
}else if(time >= 11 && time <= 18){
System.out.println("Afternoon Delivery");
}else{
System.out.println("Evening Delivery");
}
}
}
//Patterns by using for loops
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns");
int c=obj.nextInt();
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
System.out.print("*");
}
System.out.println();
}
}
}
//pattern
//*
//**
///***
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns\n");
int c=obj.nextInt();
for(int i=1;i<=r;i++){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
//pattern
***
**
*
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns\n");
int c=obj.nextInt();
for(int i=r;i>=1;i--){
for(int j=1;j<=i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
//pattern
***
* *
***
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns\n");
int c=obj.nextInt();
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(i==2 && j==2){
System.out.print(" ");
}else{
System.out.print("*");
}
}
System.out.println();
}
}
}
/print the given pattern
/* * * * *
* * *
* * *
* * *
* * * * *
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns\n");
int c=obj.nextInt();
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(i==1 || i==r || j==1 ||j==c || i==j){
System.out.print(" * ");
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}
//pattern
* * * * *
* * * *
* * *
* * * *
* * * * *
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner obj=new Scanner(System.in);
System.out.print("enter no. of rows");
int r=obj.nextInt();
System.out.print("enter no.of columns\n");
int c=obj.nextInt();
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(i==1 || i==r || j==1 ||j==c || i==j || i+j==r+1){
System.out.print(" * ");
}else{
System.out.print(" ");
}
}
System.out.println();
}
}
}