TCS Digital Coding Question 1 & 2

TCS Digital Coding Question 1 & 2

13 Nov 2022

Question 2 Statement

A store has different categories of products in stock as shown below. Item Number=[101, 102, 103, 108] Item Name=[Milk, Cheese , Ghee, Bread] Price=[42, 50, 500, 40] Stock =[10, 20, 15, 16]

When user give input with 2 values as

  1. Item number for item which user wish to buy
  2. Quantity for the item entered above

When user enters above input, the code should check the stock

  1. If quantity is less than stock and item is available display a notification message showing Output Line1 [prices] INR
    Calculate total price in float with precision.
    Output Line2 quantity LEFT
    // updated stock for item after after purchase

2.If the quantity and stocks less than quantity entered by the user while placing order, then display message Output Line1 NO STOCK
Output Line2 quantity LEFT

3.If user enter character as input for item number and quantity or enter item number which is not available then display following message and stop Output Line1- INVALID INPUT Make sure the string message displayed in output.

Sample INPUT :-

101
4

Sample OUTPUT:-

168.0 INR
6 LEFT

Sample INPUT :-

104
20

Sample OUTPUT:-

NO STOCK
16 LEFT

Solution