Skip to main content

Cognizant Coding Questions and Answers 2022 - Question 5

 

Cognizant Coding Questions and Answers 2022

Problem Statement

 In a theater, there is a discount scheme announced where one gets a 10% discount on the total cost of tickets when there is a bulk booking of more than 20 tickets, and a discount of 2% on the total cost of tickets if a special coupon card is submitted. Develop a program to find the total cost as per the scheme. The cost of the k class ticket is Rs.75 and q class is Rs.150. Refreshments can also be opted by paying an additional of Rs. 50 per member.

Hint : k and q and You have to book minimum of 5 tickets and maximum of 40 at a time. If fails display “Minimum of 5 and Maximum of 40 Tickets”.  If circle is given a value other than ‘k’ or ‘q’ the output should be “Invalid Input”.

The ticket cost should be printed exactly to two decimal places.

Sample Input 1 :

Enter the no of ticket : 35

Do you want refreshment : y

Do you have coupon code : y

Enter the circle : k

Sample Output 1 :

Ticket cost : 4065.25

Sample Input 2 :

Enter the no of ticket : 1

Sample Output 2 :

Minimum of 5 and Maximum of 40 Tickets

 

 

Program :

import sys

noTicket=int(input("Enter the no of ticket: "))

if (noTicket < 5 or noTicket > 40) :

    print("\nMinimum of 5 and Maximum of 40 tickets")

    sys.exit(0)

 

ref=input("Do you want refreshment: ")

co=input("Do you have coupon code: ")

circle=input("Enter the circle: ")

 

if(circle== 'k'):

    cost=75*noTicket

elif(circle== 'q'):

    cost=150*noTicket

else:

    print("Invalid Input")

    sys.exit(0)

 

 

total=cost

if(noTicket>20):

    cost= cost - ((0.1)*cost)

total=cost

if(co== 'y'):

    total= cost - ((0.02)*cost)

if(ref== 'y'):

    total += (noTicket*50);

print("\nTicket cost:{}".format(round(total,2)))


for execution and output so check the video :




Comments

Popular posts from this blog

Hackerrank Java Coding Questions and Answers - Maximum Passengers

  Hackerrank Java Coding Questions and Answers Maximum Passengers Problem Statement -:  A taxi can take multiple passengers to the railway station at the same time.On the way back to the starting point,the taxi driver may pick up additional passengers for his next trip to the airport.A map of passenger location has been created,represented as a square matrix. The Matrix is filled with cells,and each cell will have an initial value as follows: A value greater than or equal to zero represents a path. A value equal to 1 represents a passenger. A value equal to -1 represents an obstruction. The rules of motion of taxi are as follows: The Taxi driver starts at (0,0) and the railway station is at (n-1,n-1).Movement towards the railway station is right or down,through valid path cells. After reaching (n-1,n-1) the taxi driver travels back to (0,0) by travelling left or up through valid path cells. When passing through a path cell containing a passenger,the passe...

HackerRank Java Coding Questions and Answers - Disk Space Analysis

  HackerRank   Java   Coding   Questions   and   Answers Disk Space Analysis Problem Statement -:   You are given an array, You have to choose a contiguous subarray of length ‘k’, and find the minimum of that segment, return the maximum of those minimums. Sample input 1 →  Length of segment x =1 5 →  size of space n = 5 1 → space = [ 1,2,3,1,2] 2  3  1  2  Sample output 3 Explanation The subarrays of size x = 1 are [1],[2],[3],[1], and [2],Because each subarray only contains 1 element, each value is minimal with respect to the subarray it is in. The maximum of these values is 3. Therefore, the answer is 3   Program :   // Hackerrank Java Coding Questions and Answers //   Disk Space Analysis   import java.util.*; class DiskSpace {   public static void main(String[] args) {   Scanner sc=new Scanner(System.in);   System.out.println...

TCS CodeVita Coding Questions with Answers - Counting Rock Sample

  TCS CodeVita Coding Questions with Answers Counting Rock Sample Problem Description Question – :  Juan Marquinho is a geologist and he needs to count rock samples in order to send it to a chemical laboratory. He has a problem: The laboratory only accepts rock samples by a range of its size in ppm (parts per million). Juan Marquinho receives the rock samples one by one and he classifies the rock samples according to the range of the laboratory. This process is very hard because the number of rock samples may be in millions. Juan Marquinho needs your help, your task is to develop a program to get the number of rocks in each of the ranges accepted by the laboratory. Input Format :  An positive integer S (the number of rock samples) separated by a blank space, and a positive integer R (the number of ranges of the laboratory); A list of the sizes of S samples (in ppm), as positive integers separated by space R lines where the ith line containing two positive...