ELECTRICITY BILL
import java.util.*;
class praveen{
public static void main(String args[]){
double cost,n;
Scanner sc=new Scanner(System.in);
String i=sc.nextLine();
String name=sc.nextLine();
n=sc.nextDouble();
if(n<199)
cost=1.20*n;
else if(n<400)
cost=1.5*n;
else if(n<600)
cost=1.8*n;
else
cost=2*n;
if(cost>400)
cost=(15/100.0)*cost+cost;
else
cost=cost+100;
System.out.format("%.2f",cost);
}
}
class praveen{
public static void main(String args[]){
double cost,n;
Scanner sc=new Scanner(System.in);
String i=sc.nextLine();
String name=sc.nextLine();
n=sc.nextDouble();
if(n<199)
cost=1.20*n;
else if(n<400)
cost=1.5*n;
else if(n<600)
cost=1.8*n;
else
cost=2*n;
if(cost>400)
cost=(15/100.0)*cost+cost;
else
cost=cost+100;
System.out.format("%.2f",cost);
}
}
Display season
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
if(n==4 || n==5 ||n==6)
System.out.println("Summer");
else if(n==7 || n==8 ||n==9)
System.out.println("Rainy");
else if(n==11 || n==12 ||n==1)
System.out.println("Winter");
else if(n==2 || n==3)
System.out.println("Spring");
else
System.out.println(-1);
}
}
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
if(n==4 || n==5 ||n==6)
System.out.println("Summer");
else if(n==7 || n==8 ||n==9)
System.out.println("Rainy");
else if(n==11 || n==12 ||n==1)
System.out.println("Winter");
else if(n==2 || n==3)
System.out.println("Spring");
else
System.out.println(-1);
}
}
Color code
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
char n;
n=sc.next().charAt(0);
char a=Character.toUpperCase(n);
switch (a) {
case 'V':
System.out.println("Violet");
break;
case 'I':
System.out.println("Indigo");
break;
case 'B':
System.out.println("Blue");
break;
case 'G':
System.out.println("Green");
break;
case 'Y':
System.out.println("Yellow");
break;
case 'O':
System.out.println("Orange");
break;
case 'R':
System.out.println("Red");
break;
default:
System.out.println(-1);
}
}
}
Car choice
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int t,x1,x2,y1,y2;
float c1,c2;
t=sc.nextInt();
for(int i=0;i<t;i++){
x1=sc.nextInt();
x2=sc.nextInt();
y1=sc.nextInt();
y2=sc.nextInt();
c1=y1/(float)x1;
c2=y2/(float)x2;
if(c1<c2)
System.out.println(-1);
else if(c1>c2)
System.out.println(1);
else
System.out.println(0);
}
}
}
Can share equally?
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int x,y;
x=sc.nextInt();
y=sc.nextInt();
if(x==0 && y%2==0)
System.out.print("YES");
else if(x==0 && y%2!=0)
System.out.print("NO");
else if((x+2*y)%2==0)
System.out.print("YES");
else
System.out.print("NO");
}
}
Program to check vowel or consonant
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
char n;
n=sc.next().charAt(0);
if(n=='a' || n=='e'|| n=='i'|| n=='o'|| n=='u'|| n=='A'|| n=='E'|| n=='I'||
n=='O'|| n=='U')
System.out.print("Vowel");
else
System.out.print("Consonant");
}
}
check if number is even or odd
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
if(n%2==0)
System.out.print("Even");
else
System.out.print("Odd");
}
}
program to check whether the given integer is positive or negative
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n,a;
n=sc.nextInt();
if(n<0)
System.out.print("Negative Number");
else
System.out.print("Positive Number");
}
}
Grades of rides
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int a,b,c;
boolean x,y,z;
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
x=a>50;
y=b>60;
z=c>100;
if(x && y && z)
System.out.print(10);
else if(x && y)
System.out.print(9);
else if(y && z)
System.out.print(8);
else if( x && z)
System.out.print(7);
else if(x || y || z)
System.out.print(6);
else
System.out.print(5);
}
}
Rain drop
import java.util.*;
class praveen{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n;
n=sc.nextInt();
if(n%3==0)
System.out.print("Pling");
if(n%5==0)
System.out.print("Plang");
if(n%7==0)
System.out.print("Plong");
if(n%3!=0 && n%5!=0 && n%7!=0)
System.out.print(n);
}
}