Home Paper Capgemini Coding Questions

Capgemini Coding Questions

by Anup Maurya
3 minutes read

6. Problem Statement : Bela teaches her daughter to find the factors of a given number. When she provides a number to her daughter, she should tell the factors of that number. Help her to do this, by writing a program. Write a class FindFactor.java and write the main method in it.

Note :
If the input provided is negative, ignore the sign and provide the output. If the input is zero
If the input is zero the output should be “No Factors”.

Sample Test Case
Input:
54
Output :
1, 2, 3, 6, 9, 18, 27, 54

7. Problem Statement : Raj wants to know the maximum marks scored by him in each semester. The mark should be between 0 to 100 ,if it goes beyond the range display “You have entered invalid mark.”

Sample Test Case
Input 1:
Enter no of semester:3
Enter no of subjects in 1 semester:3
Enter no of subjects in 2 semester:4
Enter no of subjects in 3 semester:2
Marks obtained in semester 1:506070
Marks obtained in semester 2:90987667
Marks obtained in semester 3:8976
Output 1:
Maximum mark in 1 semester:70
Maximum mark in 2 semester:98
Maximum mark in 3 semester:89

8. Problem Statement : Mayuri buys “N” no of products from a shop. The shop offers a different percentage of discount on each item. She wants to know the item that has the minimum discount offer, so that she can avoid buying that and save money.[Input Format: The first input refers to the no of items; the second input is the item name, price and discount percentage separated by comma(,)]Assume the minimum discount offer is in the form of Integer.

Note: There can be more than one product with a minimum discount.

Sample Test Case
Sample Input 1:
4
mobile,10000,20
shoe,5000,10
watch,6000,15
laptop,35000,5
Sample Output 1:
shoe

Explanation: The discount on the mobile is 2000, the discount on the shoe is 500, the discount on the watch is 900 and the discount on the laptop is 1750. So the discount on the shoe is the minimum.

9. Problem Statement: You have write a function that accepts, a string which length is “len”, the string has some “#”, in it you have to move all the hashes to the front of the string and return the whole string back and print it.

char* moveHash(char str[],int n);
Sample Test Case
Input:
Move#Hash#to#Front
Output:
MoveHashtoFront

10. Problem Statement : Shraddha Kapoor’s professor suggested that she study hard and prepare well for the lesson on seasons. If her professor says month then, she has to tell the name of the season corresponding to that month. So write the program to get the solution to the above task?

  • March to May – pring Season
  • June to August – Summer Season
  • September to November – Autumn Season
  • December to February – Winter Season

Note: The entered month should be in the range of 1 to 12. If the user enters a month less than 1 or greater than 12 then the message “Invalid Month Entered” should get displayed.

Sample Test Case
Input 1:
Enter month: 6
Output 1:
Season: Summer

related posts

Leave a Comment

Enable Notifications OK No thanks