Solved Paper For Icse Computer Applications 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

QUESTION 3

import java.util.*;
public class Eshop
{
String name;
double price;

public void accept()


{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the name of the item: ");
name = scanner.nextLine();
System.out.print("Enter the price of the item: ");
price = scanner.nextDouble();
}

public void calculate()


{
double discount = 0.0;
if (price >= 1000 && price <= 25000) {
discount = 0.05;
} else if (price > 25000 && price <= 57000) {
discount = 0.075;

} else if (price > 57000 && price <= 100000) {


discount = 0.1;
} else if (price > 100000) {
discount = 0.15;
}
price = price - (price * discount);

public void display()


{
System.out.println("Name of the Item: " + name);
System.out.println("Net amount to be paid: " + price);
}

public static void main(String[] args) {


Eshop eshop = new Eshop();
eshop.accept();
eshop.calculate();
eshop.display();
}
}
QUESTION 4
import java.util.*;
class selection
{
public static void main(String args[])
{
int arr[];
arr=new int[10];
Scanner sc=new Scanner(System.in);
System.out.println("Enter 10 numbers");
for(int i=0;i < 10;i++)
{
arr[i]=sc.nextInt();
}
System.out.println("Original array:");
for(int i=0;i < 10;i++)
{
System.out.print(arr[i]+" ");
}
for(int i=0;i < 10;i++)
{
int index = i;
for(int j= i+1;j < 10;j++)
{
if(arr[j] < arr[index])
{
index = j;
}
}
int temp = arr[i];
arr[i] = arr[index];
arr[index] = temp;
}
System.out.println("Sorted array:");
for(int i=0;i < 10;i++)
{
System.out.print(arr[i]+" ");
}
}
}
QUESTION 5

import java.util.*;
class Vow
{
public static void main(String args[])
{
String str;int count=0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the word:");
str = sc.next();
str=str.toUpperCase();
System.out.println("Output:"+str);
for(int i=0;i< str.length();i++)
{
char c=str.charAt(i);

if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
{
count+=1;

}
}
System.out.println("Number of Vowels:"+count);
}
}

QUESTION 6

import java.util.*;
class accept
{
public static void main(String args[])
{
int a[][],counteven=0,countodd=0;
a=new int[3][3];
Scanner sc=new Scanner(System.in);
System.out.println("Enter the array elements");
for(int i=0;i< 3;i++)
{
for(int j=0;j< 3;j++)
{
a[i][j]=sc.nextInt();
}
}

for(int i=0;i< 3;i++)


{
for(int j=0;j< 3;j++)
{
if(a[i][j]%2==0)
{

counteven+=a[i][j];
}
else{
countodd+=a[i][j];
}
}}

if(counteven==countodd)
{
System.out.println("Special array");
}

else{
System.out.println("Not a Special array");
}
}
}

QUESTION 7

import java.util.*;
class duck
{
public static void main(String args[])
{
int num;boolean check=false;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number:");
num = sc.nextInt();

while(num!=0)
{
int d=num%10;
if(d==0)
check=true;
num/=10;
}

if(check)
System.out.println("Duck Number");
else
System.out.println("Not Duck Number");
}
}
QUESTION 8

You might also like