473,508 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with two functions

20 New Member
Well my program is to convert an octal number to the decimal form. Im not that far into it because i cant get the two functions in without a compile error coming up. Heres what i got so far.

Expand|Select|Wrap|Line Numbers
  1. import java.util.Scanner;
  2.  
  3. public class test
  4. {
  5. public static void main ( String args[] )
  6.  {
  7. Scanner in = new Scanner ( System.in );
  8. int value = 0;
  9.  
  10. while ( ( value < 1 ) || ( value > 99999999 ) )
  11.  {
  12. System.out.print ("Enter up to an 8-digit octal number and I'll convert it: ");
  13. value = in.nextInt();
  14.  }
  15. }
  16.  
  17. public static int convert ( int value )
  18. {
  19.  
  20. int a, b, c, d, e, f, g, h, num1 = 100000000, num2 = 10000000, num3 = 1000000, num4 = 100000, num5 = 10000, num6 = 1000, num7 = 100, 
  21. num8 = 10, num9 = 1;
  22.  
  23. a = value % num1 / num2;
  24. b = value % num2 / num3;
  25. c = value % num3 / num4;
  26. d = value % num4 / num5;
  27. e = value % num5 / num6;
  28. f = value % num6 / num7;
  29. g = value % num7 / num8;
  30. h = value % num8 / num9;
  31.  
  32. }
  33.  
  34. }
this is the error that comes up..


test.java:36: missing return statement
}
^
1 error

If i try to fix it i just get more errors. Help is greatly appreciated.
Nov 4 '08 #1
2 1274
r035198x
13,262 MVP
When you write, public static int convert (... you are saying that the method convert returns an int. The compiler therefore expects to find a return statement in that method which returns a value of type int. If the compiler doesn't find that return then it will tell you that your code is missing a return.
Nov 4 '08 #2
JosAH
11,448 Recognized Expert MVP
Here's a hint: check out the Integer.parseInt() methods; they're static methods.

kind regards,

Jos
Nov 4 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
1676
by: sinisam | last post by:
Object oriented programming is not a new term to me, but when I tried to do some of it... uhh... it sure looked (and felt) like Hell :) I won't bother about things like "help me learn it" (but...
8
2827
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
5
1917
by: ganesh.gella | last post by:
Hi All, Wanted to make sure on this, I have some functions for which I am providing the definition inside the class definition. (As these are very small functions like get and set). Do i...
15
1978
by: Felix Kater | last post by:
Hi, in a given library I register callback functions with this function: bool set_callback(int index, int (*callback_function)(long)); I need the callback function to also pass the index...
10
2247
by: mark | last post by:
I have this class: class Selections { OSStatus Init(); protected: CFMutableSetRef selectionObjects; static void CFASelectionsApplier(const void* value, void* ctx); OSType ready; public:...
21
3171
by: Johan Tibell | last post by:
I would be grateful if someone had a minute or two to review my hash table implementation. It's not yet commented but hopefully it's short and idiomatic enough to be readable. Some of the code...
18
2307
by: bsruth | last post by:
I tried for an hour to find some reference to concrete information on why this particular inheritance implementation is a bad idea, but couldn't. So I'm sorry if this has been answered before....
21
2512
by: asif929 | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
32
3006
by: lcdgoncalves | last post by:
Hi everyone Is there a real need to use keyword static with functions, if we simply don't declare their prototypes in .h file? Many textbooks avoid to discuss this matter and/or discuss only...
10
2087
by: CuTe_Engineer | last post by:
hii, i have cs assignment i tried to solve it but i still have many errors , plzz help mee :"< it`s not cheating becuz i`ve tried & wrote the prog. i just wanna you to show me my mistakes ...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.