SOLVE COMPUTER APPLICATION SET-1 2022

Maximum Marks: 50

Time allowed: One and a half hours

Answers to this Paper must be written on the paper provided separately.

You will not be allowed to write during the first 10 minutes.

This time is to be spent reading the question paper.

The time given at the head of this Paper is the time allowed for writing the answers.

Attempt all questions from Section A and any four questions from Section B.

SECTION A

(Attempt all questions.)

Welcome to your Computer Basics

Name
School
Class
Phone
By using internet we can download.

Which one is Input device?

This is a flat input device that usually sits in front of the monitor.

Answer The Following

which one is basic part of computer?

www.xyz.com is________________

which is the logical part of computer?

What is the other name used for computer programs and information?

The part of a computer that allows the user to view information on a screen is called:

Answer The Following

Section-B

(Attempt any four questions)

2. Write a program in Java to store 20 temperatures in °F in a Single Dimensional Array (SDA) and display all the temperatures after converting them into °C.

Hint: (c/5) = (f – 32) / 9

import java.util.*;  
public class Main  
{   
public static void main(String args[])   
{    
Scanner in = new Scanner(System.in);

double arr[] = new double[5];
int i,n;
double tc,tf;

System.out.println("Enter The No Of Term");            
n = in.nextInt();            
                    
System.out.println("Enter " + n + " temperatures in degree Fahrenheit");            
for (i = 0; i < n; i++)    
{                
arr[i] = in.nextDouble();            
}  

System.out.println("Temperatures in degree Celsius");  

for (i = 0; i < n; i++)    
{   
    tf=arr[i];
    tc = (double)5 * ((tf - 32) / 9);                
    System.out.println(tc);            
}

}  
}

Output:

Enter The No Of Term
5
Enter 5 temperatures in degree Fahrenheit
45
55
65
75
85
Temperatures in degree Celsius
7.222222222222222
12.777777777777777
18.333333333333332
23.88888888888889
29.444444444444446

3. Write a program to input a sentence. Find and display the following:

(i) Number of words present in the sentence
(ii)Number of letters present in the sentence

Assume that the sentence has neither included any digit nor a special character.

import java.util.*; 
public class WordsNLetters  
{      
public static void main(String args[])   
{           
Scanner in = new Scanner(System.in);
int wc,lc,l,i;
char ch;
String st;

System.out.println("Enter a sentence:");           
st = in.nextLine();

wc=0;
lc=0;
st=st+' '; 

l = st.length();

for (i = 0; i < l; i++)    
{               
ch = st.charAt(i);               
if (ch == ' ')                   
wc++;               
else                   
lc++;           
} 

System.out.println("No. Of Words = " + wc); 
System.out.println("No. Of Letters="+lc);      
}  
} 

Output:

Enter a sentence:
Welcome To BeeOwn
No. Of Words = 3
No. Of Letters=15

4. Write a program to accept the name and total marks of N number of students in two single subscript arrays name[ ] and totalmarks[ ].
Calculate and print:

(i) The average of the total marks obtained by N number of students.

[average = (sum of total marks of all the students)/N]


(ii) Deviation of each student’s total marks with the average.

[deviation = total marks of a student – average]
import java.util.*;  
public class Array  
{       
public static void main(String args[])   
{            
Scanner in = new Scanner(System.in);

int i,n,gt; // gt for Grand Total
double avg,devi; //devi for Deviation

System.out.print("Enter number of students: ");            
n = in.nextInt();
                    
String name[] = new String[n];     // Store Name       
int tm[] = new int[n];   //Store Total Marks

gt = 0;
                    
for (i = 0; i < n; i++)    
{
in.nextLine();  

System.out.print("Enter name of student " + (i+1) + ": ");                
name[i] = in.nextLine();                
System.out.print("Enter total marks of student " + (i+1) + ": ");                
tm[i] = in.nextInt();                
gt =gt + tm[i];            
} 
                           
avg = (double)gt /n;     //Calculating Average       
System.out.println("Average = " + avg);   
                 
for (i = 0; i < n; i++)    
{ 
    devi=tm[i] - avg;
    System.out.println("Deviation for " + name[i] + " = " + (devi));            
}       
}  
} 

Output:

Enter number of students: 5
Enter name of student 1: Manoj Mahato
Enter total marks of student 1: 95
Enter name of student 2: Abhijeet Choudhree
Enter total marks of student 2: 94
Enter name of student 3: Bikash Singh
Enter total marks of student 3: 93
Enter name of student 4: Avinash Kumar
Enter total marks of student 4: 93
Enter name of student 5: Jayshree Mahato
Enter total marks of student 5: 75
Average = 90.0
Deviation for Manoj Mahato = 5.0
Deviation for Abhijeet Choudhree = 4.0
Deviation for Bikash Singh = 3.0
Deviation for Avinash Kumar = 3.0
Deviation for Jayshree Mahato = -15.0

5. Write a program in Java to accept a name(Containing three words) and Display only the initials (i.e., the first letter of each word).

Sample Input: NARAYAN KUMAR DEY
Sample Output: N K D

import java.util.*;  
public class FirstLetter  
{       
public static void main(String args[])   
{            
Scanner in = new Scanner(System.in); 
String st, st1;
int l,i;
char ch,ch1;
System.out.println("Enter a name having more than 3 words:");            
st = in.nextLine();

st1="";            
st = ' '+st; 
l = st.length();

for (i = 0; i < l; i++)    
{                
ch = st.charAt(i);                
if (ch ==' ')     
{ 
    ch1 = st.charAt(i+1);
    st1 = st1+ch1+' ';      
}    
}

System.out.print("First Letter Of Each Word " + st1);
}  
} 

Output:

Enter a name having more than 3 words:
NARAYAN KUMAR DEY
First Letter Of Each Word N K D 

6. Write a program in Java to accept a name containing three words and display the surname first, followed by the first and middle names.

Sample Input: LALA MOHENDAR AMARNATH
Sample Output: AMARNATH LALA MOHENDAR

import java.util.*;  
public class SurnameFirst  
{   
public static void main(String args[])   
{           
Scanner in = new Scanner(System.in);
String name,sname,iname;
int p;
System.out.println("Enter a name having more than  3 words:");           
name = in.nextLine();           
p = name.lastIndexOf(' ');                
sname = name.substring(p + 1);           
iname = name.substring(0, p);                  
System.out.println(sname + ' ' + iname);       
}  
} 

Output:

Enter a name having more than  3 words:
LALA MOHENDAR AMARNATH
AMARNATH LALA MOHENDAR

7. Write a program in Java to enter a String/Sentence and display the longest word and the length of the longest word present in the String.

Sample Input: “SOURAV GANGULY IS THE PRESIDENT OF BCCI”
Sample Output:

The longest word: PRESIDENT

The length of the word: 9

import java.util.*;  
public class LongestWord  
{       
public static void main(String args[])   
{           
Scanner in = new Scanner(System.in);
int h,i,l,l1;
String st,st1,st2;
char ch;
System.out.println(“Enter a word or sentence:”);           
st = in.nextLine();                  
st = st+' '; //Add space at end of string           
st1= " ";
st2 =" ";
h=0;
l = st.length();                  
for (i = 0; i < l; i++)     
{               
ch = st.charAt(i);               
if (ch != ' ')     
{                                   
st1=st1+ch;
}               
else      
{                   
l1=st1.length();
if(l1>h)
{
    h=l1;
    st2=st1;
}
st1=" ";
}           
}           
System.out.println("The longest word: " + st2);
System.out.println("The length of the word: " +(h-1));       
}  
} 

Output:

Enter a word or sentence:
SOURAV GANGULY IS THE PRESIDENT OF BCCI
The longest word:  PRESIDENT
The length of the word: 9
Share your love