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

Batch 28 Task-1

The document contains 5 programming problems: 1) A program to calculate the cube of a number taken from command line input. 2) A program to calculate the area of a rectangle given length and breadth from user input. 3) A program to calculate the sum and average of 3 numbers taken from command line input. 4) A program to interchange two numbers without a third variable and taking numbers from command line input. 5) A program to calculate tax on a taxable income of Rs. 9,90,000 at a rate of 4.9%.

Uploaded by

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

Batch 28 Task-1

The document contains 5 programming problems: 1) A program to calculate the cube of a number taken from command line input. 2) A program to calculate the area of a rectangle given length and breadth from user input. 3) A program to calculate the sum and average of 3 numbers taken from command line input. 4) A program to interchange two numbers without a third variable and taking numbers from command line input. 5) A program to calculate tax on a taxable income of Rs. 9,90,000 at a rate of 4.9%.

Uploaded by

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

1) Write a program to find out the cube of a number where number must be taken

from command line argument.


import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter an integer -: ");
int a =sc.nextInt();
System.out.println("cube of the number -: "+(a*a*a));
}
}

2) Write a program to find out the area of Rectangle where length and breadth
of the Rectangle must be taken from user.
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("length of the rectangle -: ");
int l =sc.nextInt();
System.out.print("breath of the rectangle -: ");
int b =sc.nextInt();
System.out.println("Area of the rectangle -: "+(l*b));
}
}

3) Write a program to find the sum and average of three numbers where number
must be taken from command line argument.

4) Write a program to interchange the value of two numbers without using the
third variable where number must be taken from command line argument.

5) Write a program to calculate the tax for a taxable income of Rs.


9,90,000, if the tax rate is fixed at 4.9%.

import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("enter a number -: ");
int x=sc.nextInt();
int y=x*x*x;
System.out.println("cube of the "+x+" is "+y);
System.out.print("length -:");
x=sc.nextInt();
System.out.print("breadth -:");
y=sc.nextInt();
int z=x*y;
System.out.println("Area of the rectangle length "+x+" and breadth "+y+"
is "+z);
System.out.println("enter the two values:-");
System.out.print(" x=");
x=sc.nextInt();
System.out.print(" y=");
y=sc.nextInt();
x=x+y;
y=x-y;
x=x-y;
System.out.print(" x="+x);
System.out.println(" y="+y);
System.out.println("enter any three values-: ");
System.out.print(" x="); x=sc.nextInt();
System.out.print(" y="); y=sc.nextInt();
System.out.print(" z="); z=sc.nextInt();
z=x+y+z;
x=z/3;
System.out.println("Sum of three numbers is "+z+" and the average is
"+y);
}
}

You might also like