Question: Java i keep getting this error error: missing return statement } ^ This is in my second file ProblemSolution. the Question is Write a program

Java i keep getting this error

error: missing return statement } ^

This is in my second file ProblemSolution.

the Question is

Write a program that gets a three-digit integer (99

import java.util.*; import java.lang.*; import java.io.*;

class DriverMain{ public static void main(String args[]){ ProblemSolution problemSolution = new ProblemSolution(); // Display result System.out.print(problemSolution.sum()); } }

import java.util.*; import java.lang.*; import java.io.*;

/* Write your Analysis (What is the problem):

*/

/* Write your Design (How to solve the problem):

*/

class ProblemSolution{ public int sum(){ Scanner input = new Scanner(System.in); System.out.print("Input an integer between 100 and 999: "); int num = input.nextInt(); if (num <= 99 || num >= 1000){ System.out.print("-1"); } else{ int firstDigit = num % 10; int remainingNumber = num / 10; int SecondDigit = remainingNumber % 10; remainingNumber = remainingNumber / 10; int thirdDigit = remainingNumber % 10; int sum = thirdDigit + SecondDigit + firstDigit; System.out.println (sum); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!