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

Question New

The document contains three questions related to programming concepts. The first question contains a function to check if a number is an Armstrong number, with placeholders to be filled in. The subsequent parts ask to identify the code needed for each placeholder. The second question involves a process to find the palindrome of a two digit number by reversing and summing digits until a palindrome is reached, up to 15 steps. The third question involves a program to calculate discounts on purchases for dealers and retailers based on payment days, and print details of the customer with maximum discount.

Uploaded by

sanjay choudhary
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)
54 views

Question New

The document contains three questions related to programming concepts. The first question contains a function to check if a number is an Armstrong number, with placeholders to be filled in. The subsequent parts ask to identify the code needed for each placeholder. The second question involves a process to find the palindrome of a two digit number by reversing and summing digits until a palindrome is reached, up to 15 steps. The third question involves a program to calculate discounts on purchases for dealers and retailers based on payment days, and print details of the customer with maximum discount.

Uploaded by

sanjay choudhary
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/ 2

REFLEXES Time :1 hour

Dated:
Assignment:2 2018/PLT
1)The following is a function of some class which checks if a positive integer is an
Armstrong number by returning true or false. (A number is said to be Armstrong if
the sum of the cubes of all its digits is equal to the original number
.)The functiondoes not use modulus (%) operator to extract digit. There are some places in thecode marked by?
1?, ?2?, ?3?, ?4?, ?5?which may be replaced by a statement/expression so that the function works properly.
boolean ArmstrongNum( int N )
{
int sum=?1?;
int num=N;
while( num>0)
{
int f= num/10;
int s =?2?;
int digit = num-s;
sum+=?3?;
num =?4?;
}
if(?5?)
return true;
else
return false;
}
(i)What is the statement or expression at?1?
(ii)What is the statement or expression at?2?
(iii)What is the statement or expression at?3?
(iv)What is the statement or expression at?4?
(v)What is the statement or expression at?5?

Question 2:
A palindrome no is a number which read same from forward and reverse. For example 151, 232, 4334 etc. A mathematician as
followed some other process for finding a p[alindrome of a number having two or more digits as follows:
Step 1 : Reverse the digits of the original number.
Step 2 : add the reverse number and the original number to get a new number.
Step 3 : If the new number is a palindrome number, means the number is found as palindrome otherwise repeat all above steps by
taking new no as the original number till a palindrome number is not obtained. Repeat your process upto maximum of 15 steps.
For example : Input: num=78
Step 1 Step 2 step 3 step4
Number: 78 165 726 1353
Reverse: 87 561 726 3531
--- ---- ---- -----
Sum: 165 726 1353 4884
(new number)-- ---- ----- -----
Output: num=78 its palindrome number =4884 and found in step 4

R e f l e x e s:Sans cloud computing and application development: [email protected]


Question 3: A company deals with 2 types of customers(i.e.: dealer and retailer) for selling his goods. The company also offers discount
to the dealer and retailer at the time of purchasing goods, as per the tariff given below:[15]

Days of payment Discount of Dealer Discount of Retailer


Within 30 days 15% 10%
31 to 45 days 10% 5%
46 to 60 days 5% 2%
More than 60 days No discount No discount
Write.a.programme in java to accept:
i)The no of days within which the bill is to be paid.
ii)The type of customer ’D’ for dealer and ‘R’ for retailer
iii)The amount of purchase
for n number of customers
The program displays the details to the customer at the time of paying bill
Also print the details of The customer whose discount was maximum.

R e f l e x e s:Sans cloud computing and application development: [email protected]

You might also like