Results 1 to 5 of 5
- 10-21-2012, 05:31 AM #1
Member
- Join Date
- Oct 2012
- Posts
- 10
- Rep Power
- 0
can u tell me w/c one is correct?
im trying to figure out w/c one displays the largest number among the individual digits of my input.
cuz im using windows now cant run them.
Java Code:import java.util.Scanner; class Largest{ public static void main(String args[]){ Scanner x = new Scanner(System.in); int value = -1; int counter = 0; do{ System.out.println(Enter an integer:"); int tmp = x.nextInt(); if (tmp > value) value = tmp; counter++; }while (counter < 5); System.out.println("Largest interger entered was >>" + value); } }
this is the second one:
Java Code:import java.util.Scanner; class Largest{ public static void main(String args[]){ Scanner i = new Scanner(System.in); int r = 0; int q = 0; int n = 0; int larger = 0; System.out.println("Enter input:"); n = i.nextInt(); for (q<10;){ q = n/10; r = n%10; System.out.println("Quotient:" + q); System.out.println("Remainder:" + r); larger = Math.max(q, r); } System.out.println("The larger number is:" + larger); } }
- 10-21-2012, 06:31 AM #2
- 10-21-2012, 06:45 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 10
- Rep Power
- 0
Re: can u tell me w/c one is correct?
i mean which one displays the largest number among the individual digits of my input.
:D
w/c = which
- 10-21-2012, 09:00 AM #4
Member
- Join Date
- Mar 2012
- Posts
- 26
- Rep Power
- 0
Re: can u tell me w/c one is correct?
both of them have syntax errors here's an online compiler, if you can't run it on your windows for some reason, Ideone.com | Online IDE & Debugging Tool >> C/C++, Java, PHP, Python, Perl and 40+ compilers and interpreters if you don't trust the link then google one...once you get the programs to work you can test both of them see which one works better for you
Last edited by romero4742; 10-21-2012 at 09:01 AM. Reason: url correction
- 10-21-2012, 10:03 AM #5
Re: can u tell me w/c one is correct?
Please use proper words. This is a technical forum, not SMS chat.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Please help - can't seem to correct this...
By jmjbreezin in forum New To JavaReplies: 7Last Post: 05-09-2011, 01:39 PM -
How to compute or know the correct value for Xmx and xms?
By icesnake in forum New To JavaReplies: 5Last Post: 06-08-2010, 04:22 PM -
Are my comments correct?
By twiggy62 in forum New To JavaReplies: 2Last Post: 02-08-2010, 05:34 AM -
Syntax correct?
By dbashby in forum New To JavaReplies: 5Last Post: 09-22-2009, 06:44 AM -
Is this the correct Output?
By Teny in forum New To JavaReplies: 17Last Post: 04-13-2009, 12:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks