# Computer Application Specimen 2024: Sec-B ICSE Sample Model Paper Solved

Computer Application Specimen 2024: Sec-B ICSE Sample Model Paper Solved by expert teachers. These solutions of ICSE Specimen paper 2024 are fully applicable as latest prescribe guideline of CISCE for upcoming board exam.

## Computer Application Specimen 2024: Sec-B ICSE Sample Model Paper Solved

 Board ICSE Class 10th (x) Subject Computer Application Topic Specimen Paper Solved Sec B Question Number Que-3 to 8 Session 2023-24 Max mark 80

### Sec-B Computer Application Specimen 2024 ICSE

#### Question 3  Define a class called with the following specifications:

Class name: Eshop

Member variables:
String name: name of the item purchased
double price: Price of the item purchased

Member methods:
void accept(): Accept the name and the price of the item using the methods of Scanner class.
void calculate(): To calculate the net amount to be paid by a customer, based on the following criteria:

Price Discount
1000 – 25000 5.0%
25001 – 57000 7.5 %
57001 – 100000 10.0%
More than 100000 15.0 %

void display(): To display the name of the item and the net amount to be paid.

Write the main method to create an object and call the above methods.

Ans:-

```import java.util.Scanner;
public class Eshop
{
private String name;
private double price;
private double disc;
private double amount;

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

public void calculate() {
double d = 0.0;

if (price < 1000)
d = 0.0;
else if (price <= 25000)
d = 5.0;
else if (price <= 57000)
d = 7.5;
else if (price <= 100000)
d = 10.0;
else
d = 15.0;

disc = price * d / 100.0;
amount = price - disc;

}

public void display() {
System.out.println("Item Name: " + name);
System.out.println("Net Amount: " + amount);
}

public static void main(String args[]) {
Eshop obj = new Eshop();
obj.accept();
obj.calculate();
obj.display();
}
}```

#### Question 4 Define a class to accept values in integer array of size 10. Sort them in an ascending order using selection sort technique. Display the sorted array.

Ans:-

```import java.util.Scanner;

public class KboatSelectionSort
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int arr[] = new int[10];
System.out.println("Enter 10 integers: ");
for (int i = 0; i < 10; i++)
{
arr[i] = in.nextInt();
}

for (int i = 0; i < 9; i++)
{
int idx = i;
for (int j = i + 1; j < 10; j++)
{
if (arr[j] < arr[idx])
idx = j;
}

int t = arr[i];
arr[i] = arr[idx];
arr[idx] = t;
}

System.out.println("Sorted Array:");
for (int i = 0; i < 10; i++)
{
System.out.print(arr[i] + " ");
}
}
}```

#### Question 5 Define a class to accept a string and convert it into uppercase. Count and display the number of vowels in it.

Input:                         robotics
Output:                      ROBOTICS
Number of vowels: 3

Ans:

```import java.util.Scanner;

public class KboatCountVowels
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the string: ");
String str = in.nextLine();
str = str.toUpperCase();
str += " ";
int count = 0;
int len = str.length();

for (int i = 0; i < len - 1; i++)
{
char ch = str.charAt(i);
if(ch == 'A'
|| ch == 'E'
|| ch == 'I'
|| ch == 'O'
|| ch == 'U')
count++;
}

System.out.println("String : " + str);
System.out.println("Number of vowels : " + count);
}
}```

#### Question 6  Define a class to accept values into a 3×3 array …. ..Sum of odd elements= 5+5+3+5=18

Ans:

```import java.util.Scanner;

public class KboatDDASpArr
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int arr[][] = new int[3][3];
long evenSum = 0, oddSum = 0;
System.out.println("Enter the elements of 3 x 3 DDA: ");
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
arr[i][j] = in.nextInt();
}
}

for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (arr[i][j] % 2 == 0)
evenSum += arr[i][j];
else
oddSum += arr[i][j];
}
}

System.out.println("Sum of even elements = " + evenSum);
System.out.println("Sum of odd elements = " + oddSum);
if (evenSum == oddSum)
System.out.println("Special Array");
else
System.out.println("Not a Special Array");
}
}```

#### Question 7  Define a class to accept a 3 digit number and check whether it is a duck number or not. Note: A number is a duck number if it has zero in it

Ans :-

```import java.util.Scanner;

public class KboatDuckNumber
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = in.nextInt();
int n = num;
int count = 0;

while (n != 0)    {
count++;
n = n / 10;
}

if (count == 3)
{
n = num;
boolean isDuck = false;
while(n != 0)
{
if(n % 10 == 0)
{
isDuck = true;
break;
}
n = n / 10;
}

if (isDuck) {
System.out.println("Duck Number");
}
else {
System.out.println("Not a Duck Number");
}
}
else {
System.out.println("Invalid");
}
}
}```

#### Question 8 Define a class to overload the method display as follows: void display(): To print the following format using nested loop …. .. 2.0

Ans :

```import java.util.Scanner;

{
public void display()
{
for(int i = 1; i <= 5; i++)
{
for(int j = 1; j <= i; j++)
{
System.out.print(j + " ");
}
System.out.println();
}
}

public void display(int n)
{
while( n != 0)
{
int d = n % 10;
System.out.println(Math.sqrt(d));
n = n / 10;
}
}

public static void main(String args[])
{
Scanner in = new Scanner(System.in);

System.out.println("Pattern: ");
obj.display();

System.out.print("Enter a number: ");
int num = in.nextInt();
obj.display(num);

}
}```

— End of Computer Application Specimen 2024: Sec-B ICSE  :-

-–: Visit also :–