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

Program 20 To 25 CA

Uploaded by

wanthkyesh
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)
16 views

Program 20 To 25 CA

Uploaded by

wanthkyesh
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

import java.util.

Scanner;
public class items
{
private String name;
private int price;
private double dis;
private double amt;
public Lap(String s, int p)
{
name = s;
price = p;
}
public void compute() {
if (price <= 25000)
dis = price * 0.05;
else if (price <= 50000)
dis = price * 0.075;
else if (price <= 100000)
dis = price * 0.1;
else
dis = price * 0.15;

amt = price - dis;


}

public void display() {


System.out.println("Name: " + name);
System.out.println("Discount: " + dis);
System.out.println("Amount to be paid: " + amt);
}

public static void main(String args[]) {

Scanner in = new Scanner(System.in);


System.out.print("Enter Customer Name: ");
String str = in.nextLine();
System.out.print("Enter Price: ");
int p = in.nextInt();

Laptop obj = new Laptop(str,p);


obj.compute();
obj.display();
}
}

Enter details of the customer:


Name : Jerry simson
Address : Mr.Jerry
15/7 willow street
Purchased item : L

Price : 100000

Discount : 75000
import java.util.Scanner;

public class resultant

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

int P[] = new int[6];

int Q[] = new int[4];

int R[] = new int[10];

int i = 0;

System.out.println("Enter 6 elements of array P:");

for (i = 0; i < P.length; i++) {

P[i] = in.nextInt();

System.out.println("Enter 4 elements of array Q:");

for (i = 0; i < Q.length; i++) {

Q[i] = in.nextInt();

i = 0;

while(i < P.length) {


R[i] = P[i];

i++;

int j = 0;

while(j < Q.length) {

R[i++] = Q[j++];

System.out.println("Elements of Array R:");

for (i = 0; i < R.length; i++) {

System.out.print(R[i] + " ");

Enter 6 elements of P:

Enter 4 elements of Q:
7

24

16

import java.util;*

class Main

public static void main(String[] args)


{

int n = 20

System.out.println("Fibonacci Series till " + 20 + " terms:");


for (int i = 1; i <= n; ++i)
{
System.out.print(firstTerm + "1 ");

int a = sc.nextInt(20);

int term = first term + second term;


second term = next term;
}
}

Enter 20 terms of Fibonacci series:


(0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 54 , 89 , 144 , 233 ,
377 , 610 , 987 , 1597 ,2584 , 4181)
java.util.Scanner;*

class CalculateCommission
{

public static void main(String arg[])


{

Scanner sc=new Scanner(System.in);

System.out.print("Enter amount:");

double amount=sc.nextDouble();

System.out.print("Enter commissionPercentage:");

double commissionPercentage=sc.nextDouble();

double amount=1000,commissionPercentage=15;

double commission=(commissionPercentage/100)*amount;

System.out.println("Commission amount="+commission);

Enter amount: 100000

Enter commissionPercentage: 10

Commission amount = 10000.0

Enter amount:25000

Enter commissionPercentage: 25

Commission amount=6250.0
import java.util.Scanner;

public class SelectionSort

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

double weightArr[] = new double[10];

System.out.println("Enter weights of 10 people: ");

for (int i = 0; i < 10; i++) {

weightArr[i] = in.nextDouble();

for (int i = 0; i < 9; i++) {

int idx = i;

for (int j = i + 1; j < 10; j++) {

if (weightArr[j] > weightArr[idx])

idx = j;

double t = weightArr[i];

weightArr[i] = weightArr[idx];

weightArr[idx] = t;

System.out.println("Sorted Weights Array:");


for (int i = 0; i < 10; i++) {

System.out.print(weightArr[i] + " ");

Enter weight of 10 people:

56.6

77.9

54.9

47.7

80.2

87.8

62.4

98.8

41.4

39.1

Enter sorted array:

98.8 , 87.8 , 80.2 , 77.9 , 62.4 , 56.6 , 54.9 , 47.7 , 41.4 , 39.1

You might also like