0% found this document useful (0 votes)
3 views8 pages

Program 1

computer project with java codes for class ten

Uploaded by

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

Program 1

computer project with java codes for class ten

Uploaded by

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

PROGRAM 1:

A paper roll manufacturing company offers discount to the dealer and


retailer based on the length of the paper roll as per the given criteria:
Length of paper Dealer Retailer
upto 10m 10% 8%
11m and up to 20m 15% 10%
more than 20m 20% 15%

Write a program to input the length of paper roll and the amount of
purchase. Use menu driven approach having choices(D) for dealer and (R)
for retailer to find and print the amount to be paid to the company after
discount.

import java.util.*;
class calculate
{
public static void main()
{
double l,amt,dis=0,amtdis=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the length and amount");
l=sc.nextDouble();
amt=sc.nextDouble();
System.out.println("Enter 'D' for Dealer");
System.out.println("Enter 'R' for Retailer");
char ch=sc.next().charAt(0);
switch(ch)
{

1|Page
case 'D':
if (l<=10)
dis=amt*10/100;
else if(l>10 && l<=20)
dis=amt*15/100;
else
dis=amt*20/100;
break;
case 'R':
if(l<=10)
dis=amt*8/100;
else if(l>10 && l<=20)
dis=amt*10/100;
else
dis=amt*15/100;
break;
default:
System.out.println("wrong choice");
}
amtdis=amt-dis;
System.out.println("Amount after discount="+amtdis);
}
}

2|Page
VARIABLE DESCRIPTION TABLE

Variable Type Description


l double length of the paper roll
amt double amount of paper roll
ch char choice to select menu
items
dis double to find discount
amtdis double amount after discount

OUTPUT

PROGRAM 2:

A telecom company charges the cell rate at 1.3 p/sec for using SIM used in
a Cell phone fro their consumer. However, the company offers different
schemes for recharging the SIM as per the given tariff:

3|Page
Amount of recharging Scheme
up to Rs.60 no bonus talk time
Rs.61 and upto Rs. 120 103% talk time
Rs. 121 and up to Rs.200 105% talk time
Rs. 201 and up to Rs. 500 110% talk time
more than Rs. 500 120% talk time

import java.util.*;
class recharging
{
public static void main()
{
int n, t;
double bt=0, ap=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the amount of recharging");
n=sc.nextInt();
if(n<=60)
bt=0;
else if(n>60 && n<=120)
bt=n*1.03;
else if(n>120 && n<=200)
bt=n*1.05;
else if(n>200 && n<=500)
bt=n*1.10;
else
bt=1.20;

System.out.println("Enter the duration of call in seconds");


4|Page
t=sc.nextInt();
ap=t*1.30/100;
System.out.println("The recharge amount= Rs"+n);
System.out.println("The amount after recharge= Rs"+bt);
System.out.println("The cell duration="+t);
System.out.println("The amount paid for the call= Rs"+ap);
}
}

VARIABLE DESCRIPTION TABLE


Variable Data type Description
n int To accept the amount of
recharging
t int To accept the call
duration
bt double To display the total
recharging amount
ap double To display the amount
paid for the call

OUTPUT

PROGRAM 3:

5|Page
Write a program to accept a square matrix and print the elements
above the left diagonal and below the left diagonal respectively.
import java.util.*;
class ddarray_triangles
{
public static void main ( )
{
Scanner sc=new Scanner (System.in);
int i,j;
int A[][]= new int[4][4];
System.out.println("Enter elements for a 4x4 array");
for( i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
A[i][j]=sc.nextInt();
}
}
System.out.println(" The lower triangle of ther left diagonal");
for(i=0;i<4;i++)
{
for(j=0;j<=i;j++)
{
System.out.print(A[i][j]+ "\t");
}
System.out.println();

6|Page
}
System.out.println(" The upper triangle of ther left diagonal");
for( i=0;i<4;i++)
{
for(j=0;j<4;j++)
{
if(j<i)
System.out.print("\t");
else
System.out.print(A[i][j]+ "\t");
}
System.out.println();
}
}
}

VARIABLE DESCRIPTION TABLE

VARIABLE DATA TYPE DESCRIPTION


i int For loop variable
j int For loop variable

Number of rows and columns


m int
given by the user

OUTPUT
7|Page
PROGRAM 4:

8|Page

You might also like