|
 |
 | Quick Links : | |
|
|
|
|
|
|
|
 |
|
 |
|
| Covering Chapters |
1. |
Introduction to Java and Concept of Classes (theory) |
8. |
Array (programming) |
2. |
Introduction to Java and Concept of Classes (programming) |
9. |
Functions and Constructors (theory) |
3. |
Decision Making (theory) |
10. |
Functions and Constructors (programming) |
4. |
Decision Making (programming) |
11. |
Library Classes (theory) |
5. |
Looping (theory) |
12. |
Library Classes (programming) |
6. |
Looping (programming) |
13. |
Encapsulation (theory) |
7. |
Array (theory) |
|
|
|
|
| Questions |
| Questions 20 |
Time :20 mins
Marks [15] |
| A computer dealer sells computer at the following rate : |
• |
Rs 15,000 per computer if the no. of computer is less than 20 computers. |
• |
Rs 14,000 per computer if the no. of computer is between 21 to 40 computers. |
• |
Rs. 12,000 per computer if the order is more than 40 computers. |
• |
Further more if the customer is dealing with dealer from five years or more the discount is extra 10%. Write a program to prepare a bill for any customer. |
|
| Question 21 |
Time :20 mins
Marks [15] |
| Write a program to read a string and print the following: |
(a) |
Total number of capital letters : |
(b) |
Total number of small letters : |
(c) |
Total number of digits : |
| For example if the user input “ I live in A-186, Indira Nagar”. The output should be: |
| |
Total number of capital letters : 4 |
| |
Total number of small letters : 15 |
| |
Total number of digits : 3 |
|
| Question 22 |
Time :20 mins
Marks [15] |
| Write a class named diagonal to compute the sum of the right diagonal which accepts from the user the value of 'N' and creates a double dimension array of N x N in main ( ). |
|
|
|
| Solutions Tips and Guidelines |
| Solution 20 |
Time :20 mins
Marks [15] |
| |
(A) |
class bill
{
void main (int num, int time)
{
double d=0,z=0;
if(num<=20)
d=num*15000;
if(num>20 && num<41)
d=num*14000;
if(num>40)
d=num*12000;
if(time >=5)
Z=d*.1;
System.out.println("The bill is " + (d-z));
}
}Variable description
'num' for inputting a number.
'd' for finding the bill.
'z' for finding the discount.
'time' for inputting the dealing time. |
| Output |
Input the number of computers you want to buy
45
Input the time you are dealing with this dealer
8
The bill is 486000.0 |
First we will ask the number of computers to buy 'num' and also the time of dealing between dealer and customer 'time'. After than we will use IF Else statement to choose one among the following three conditions, if it is less than or equal to 20 we will take a third variable 'd' and multiply the total number of computers with 15,000, if it is greater than 20 and less than 41 we will multiply number of computers with 14,000 or if it greater than 40 we will multiply the number of computers with 12,000 once we get the total amount of the bill in 'd' we check the dealing time if it is more than or equal to 5 years we take another variable 'z' to c |
|
|
|
|
|
 |
|
|
|
|
|
|
Copyright © 2007 www.globalclassroom.in All rights reserved. |
|
|
|