0% found this document useful (0 votes)
9 views6 pages

Class 9-Part 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Class 9-Part 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Q 6 : Solve the following :

a. Math.ceil(6.3)= 7.0

b. Math.floor(3.9)=3.0

c. Math.pow(7,3)=343.0

d. Math.sqrt(81) =9.0

e. Math.abs(-5.8) =5.8

f. Math.max(-2.8,-3.8) =-2.8

g. Math.min(2.5,3.5) =2.5

h. Math.round(8.8) =9

i. Math.round(2.4) = 2

j. Math.cbrt(64) = 4.0

import java.util.*;
class abc
{
public static void main()
{
Scanner obj=new Scanner (System.in);
System.out.println("Enter your name");
String name=obj.nextLine();

System.out.println("Enter Physics marks");


int pm=obj.nextInt();
System.out.println("Enter Chemistry marks");
int cm=obj.nextInt();
System.out.println("Enter Biology marks");
int bm=obj.nextInt();

int Total=pm+cm+bm;

double avg=Total/3;

System.out.println("Name:" + "\t" + "Physics" + "\t"+ "Chemistry" + "\t" + "Biology" + "\t" + "Total" + "\t"
+ "Average");
System.out.println(name+"\t"+pm+"\t"+cm+"\t"+bm+"\t"+Total+"\t"+avg);

}
}

import java.util.*;
class ABC
{
public static void main()
{
Scanner obj=new Scanner(System.in);
System.out.println("Enter distance travelled");
int km=obj.nextInt();
double rate=0;
if(km<=1)
rate=25;
else if(km>1 && km<=4)
rate=25+(km-1)*20;
else if(km>5 && km<=10)
rate=25+(4*20)+(km-5)*15;
else if(km>10 && km<=20)
rate=25+(4*20)+(5*15)+(km-10)*10;
else
{
rate=25+(4*20)+(5*15)+(10*10)+(km-20)*5;
}
System.out.println("Rate="+rate);
}
}

import java.util.*;
class ABC
{
public static void main()
{
Scanner obj=new Scanner(System.in);
System.out.println("Enter Salary ");
int s=obj.nextInt();
double tax=0;
if(s<=250000)
tax=s*0;
else if(s>250000 && s<=500000)
tax=0+(s-250000)*0.10;
else if(s>500000 && s<=1000000)
tax=0+(250000*0.10)+(s-500000)*0.20;
else
tax=0+(250000*0.10)+(500000*0.20)+(s-1000000)*0.30;
System.out.println(tax);
}
}
Q10 ) WAP to input 3 numbers from the user using Scanner class and print the lowest number. If equal then print
the appropriate message.

CODE:
import java.util.*;
class ABC
{
public static void main()
{
Scanner gn=new Scanner(System.in);
System.out.println("Enter first number: ");
int n1=gn.nextInt();
System.out.println("Enter second number: ");
int n2=gn.nextInt();
System.out.println("Enter third number: ");
int n3=gn.nextInt();
if(n1>n2 && n1>n3)
System.out.println(n1+" is greater");
else if(n2>n1 && n2>n3)
System.out.println(n2+" is greater");
else if(n3>n1 && n3>n2)
System.out.println(n3+" is greater");
else
System.out.println("Numbers are equal ");
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy