Product of Digits Problem Solution in Java | Capgemini ADAPT 2022 Solution using Java

Product of Digits Problem Solution in Java | Capgemini ADAPT 2022 Solution using Java
Product of Digits Problem Solution in Java | Capgemini ADAPT 2022 Solution using Java

In this post, you will get the solution to the Capgemini ADAPT 2022 solution to the problem of Product of Digits in Java. Capgemini ADAPT Java Solutions 2022, Product of Digits.

Note: The solutions are provided for learning purposes only. 

Table of Contents

Product of Digits Problem Description:


In a car racing video game, a car is an object. You can drive the car, turn the car, or stop the car when needed but you need to drive long. You will get money according to the Km you have traveled. For example, if you have traveled 123 km then the product of the km(i.e. 1*2*3 = 6) would be the amount you win. Write a program to find the product of the digits in the given input number.

It returns-1, if the input number is negative or greater than 32767, then print Invalid Input.

Note: Use Scanner to read the Inputs

Sample Input:

32

Sample Output:

6

Sample Input:

-67

Sample Output:

Invalid Input

Execution Time Limit:

10 seconds

Capgemini ADAPT 2022 – Product of Digits Problem Solution in Java:


import java.io.*;

import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;

import java.util.Scanner;

public class Source{

public static void main(String[] args){

int n, rem, prod = 1;

Scanner in = new Scanner(System.in);

n = in.nextInt();

if(n<0||n>32767)

{

System.out.println(“Invalid Input”);

System.exit(0);

}

else

{

while(n != 0)

{

rem = n%10;

prod = prod*rem;

n = n/10;

}

System.out.println(prod);

}

}

}

 

Top Companies + Batchwise Hiring Drive:


TOP COMPANIES HIRING DRIVE

BATCHWISE OFF-CAMPUS DRIVES

1. TCS OFF-CAMPUS DRIVES1. 2018 BATCH
2. INFOSYS OFF-CAMPUS DRIVES2. 2019 BATCH
3. COGNIZANT OFF-CAMPUS DRIVES3. 2020 BATCH
4. WIPRO OFF-CAMPUS DRIVES4. 2021 BATCH
5. CAPGEMINI OFF-CAMPUS DRIVES5. 2022 BATCH

 

To Stay Up-to-date, Follow us on Social Media:


1.      Join our Telegram Channel:

Click Here

2.      Like us on Facebook:

Click Here

3.      Follow us on Instagram:

Click Here

4.      Follow us on LinkedIn:

Click Here

5.      Follow us on Google News:

Click Here

 

ADAPT Different Coding Solutions:


  1. Largest Array Solution – Click Here
  2. Batsman & Bowler Solution – Click Here
  3. Instruments Problem Solution – Click Here
  4. Check Two Person Are Same – Click Here
  5. Medicine App ADAPT Solution – Click Here
  6. String Combination Capgemini ADAPT Solution – Click Here
  7. Remove”X”inString Problem Solution – Click Here
  8. Customer and Invoice ADAPT Problem Solution – Click Here
  9. Book and Author Problem Solution – Click Here
  10. Highest Feedback Problem Solution – Click Here
  11. Registered Customer Problem Solution in Java – Click Here
  12. Product of Digits Problem Solution – Click Here

Capgemini ADAPT Sprint 1 (Bus Reservation Solutions):


Capgemini ADAPT Sprint 2 (Bus Reservation System):


Study Materials for Interview Preparation (FREE MATERIALS):


  1. 240 Core Java Questions & Answers with PDF Download Link – Click Here
  2. 230+ SQL interview questions & answers pdf download – Click Here
  3. 50 LeetCode Interview Questions with Answers – PDF Notes – Click Here 
Previous articleRegistered Customer Problem Solution in Java | Capgemini ADAPT 2022 Solution using Java
Next articlePragmaEdge Off Campus Drive 2022 Freshers Hiring as Jr Associate Engineer
Job Seeker 24 provides Off-Campus Drive Updates, Engineering Job Updates, IT Job Updates, Jobs for Freshers, Private Sector Jobs, Public Sector Jobs, various Educational Opportunities, etc.