0% found this document useful (0 votes)
17 views

JavaProgram StdIX

Uploaded by

Ketan Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

JavaProgram StdIX

Uploaded by

Ketan Patel
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Studies

Class IX (2023-24)

Perform the Programs and write the code in your Computer Notebook:

1. W.A.P. to display your name, class, division, roll no.

2. W.A.P. to find addition, product, difference and modulus using two


numbers.
Ans: class Integer
{
public static void main ()
{
//Adding two number
int a,b,c; //declaring variables
a=15; // assigning the values to the variable a
b=5; //assigning value to the variable b
c=a+b; //adding by '+' operator
System.out.println("The Number is " + c);
c=a*b; //product by '*' operator
System.out.println("The Number is " + c);
c=a-b; //subtraction by '-' operator
System.out.println("The Number is " + c);
C=a%b; //finding remainder
System.out.println("The Number is " + c);
}
}

3. W.A.P. to find the area and perimeter of a rectangle

4. W.A.P. to find the area and perimeter of a rectangle; taking values from
the user
Ans:
class Rectangle
{
public static void main(int a, int b)
{
int ar=0, pr=0;
ar=a*b; //calculate the area
pr=2*(a+b); //calculate the perimeter
System.out.println("Area of rectangle: " + ar);
System.out.println("Perimeter of rectangle: " + pr);
}
}

5. W.A.P. to find the perimeter of a triangle.


Ans: The below program calculates the perimeter of triangle
public class Calc
{
public static void main(){
int side1, side2, side3;
side1 = 10;
side2 = 14;
side3 = 15;
int perimeter;
perimeter = side1 + side2 + side3;
System.out.println("The perimeter is, " + perimeter + " cm");
}
}

6. W.A.P. to find the area of the triangle. Take the input of base and height
from the user.

7. W.A.P. to calculate the diameter (2r), circumference (2∏r), area (∏r2 ),


perimeter of a circle (∏d). Take radius as 5.

8. W.A.P. to create a bill of a customer and add 5% service tax to it.


Ans:

public class Servicetax


{
public static void main (int bill)//variable bill is declared
{
Int bill=500
double total_bill; //var total_bill is declared
total_bill=bill+(bill*5.0/100.0); //calculate the total bill
System.out.println("old bill: " +bill);
System.out.println("Total bill with service tax: " +total_bill);
}
}

9. Write the above program 8; taking value of the bill from the user.

10. W.A.P. to display the literals (text book)


Ans:
public class literals
{
public static void main(){
int i = 40;
float f = 34.8f;
double d = 560938d;
byte b = 45;
char c = 'a';
boolean bl = true;
long l = 4567841;
System.out.println("Different Types of Literals used in Java");
System.out.println("-----------------------------");
System.out.println("Integer literal: " + i);
System.out.println("Float literal: " + f);
System.out.println("Double literal: " + d);
System.out.println("Byte literal: " + b);
System.out.println("Character literal: " + c);
System.out.println("Boolean literal: " + bl);
System.out.println("Long literal: " + l);
}
}
12. W.A.P. to display your name, class, division, roll no. Display the details in
the center of the screen using escape sequences.

13. W.A.P. using the escape sequences to display height, weight of 4 students

You might also like