java work
1
Name:
Anonymous
2007-10-04 13:27
import java.util.*;
public class HailStorm{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter a start number ( Must be an integer )");
int hail = scan.nextInt();
do {
if (hail % 2 == 0)
hail = (hail/2);
System.out.println(hail);
else hail = ((hail*3)+1)
System.out.println(hail);
}while (hail<= 1);
}
}
ok guis im getting some bullshit errors and im new to this crap so some real help would be sweet. Any and all suggestions would be helpful.
in b4 tl;dr and become an hero
"7 errors found:
File: C:\homework\cs121\HailStorm.java [line: 11]
Error: C:\homework\cs121\HailStorm.java:11: 'else' without 'if'
File: C:\homework\cs121\HailStorm.java [line: 11]
Error: C:\homework\cs121\HailStorm.java:11: <identifier> expected
File: C:\homework\cs121\HailStorm.java [line: 11]
Error: C:\homework\cs121\HailStorm.java:11: ';' expected
File: C:\homework\cs121\HailStorm.java [line: 12]
Error: C:\homework\cs121\HailStorm.java:12: <identifier> expected
File: C:\homework\cs121\HailStorm.java [line: 12]
Error: C:\homework\cs121\HailStorm.java:12: <identifier> expected
File: C:\homework\cs121\HailStorm.java [line: 13]
Error: C:\homework\cs121\HailStorm.java:13: class, interface, or enum expected
File: C:\homework\cs121\HailStorm.java [line: 14]
Error: C:\homework\cs121\HailStorm.java:14: class, interface, or enum expected
"
2
Name:
Anonymous
2007-10-04 13:34
You best be trolling nigger.
3
Name:
Anonymous
2007-10-04 13:37
See kids, this is why FORCED INDENTATION is a Good Thing.
4
Name:
Anonymous
2007-10-04 13:55
Even SICP wouldn't work on someone this dense.
5
Name:
Anonymous
2007-10-04 14:28
6
Name:
Anonymous
2007-10-04 14:47
>>5
Only if you are an idiot. Keep in mind that I just put a pencil in my ear to free my hands to type this post.
7
Name:
Anonymous
2007-10-04 14:55
try this:
import java.util.*;
public class HailStorm
public static void main(String[] args)
Scanner scan = new Scanner(System.in);
System.out.println("Enter a start number ( Must be an integer )");
int hail = scan.nextInt();
do
if (hail % 2 == 0)
hail = (hail/2);
System.out.println(hail);
else hail = ((hail*3)+1)
System.out.println(hail);
while (hail<= 1);
8
Name:
Anonymous
2007-10-04 14:56
9
Name:
Anonymous
2007-10-04 16:31
public class HailStorm{
public static void main(String[] args){
java.util.Scanner scan = new java.util.Scanner(System.in);
System.out.println("Enter a start number ( Must be an integer )");
int hail = scan.nextInt();
do{ // Fuck you
if(hail%2==0){
hail=(hail/2);
System.out.println(hail);}
else(hail=((hail*3)+1))
System.out.println(hail);
}while (hail<=1);
}
}
10
Name:
Anonymous
2007-10-04 16:32
else if(hail==((hail*3)+1))
Whoops.
11
Name:
Anonymous
2007-10-04 16:36
>>1
CS students asking for halp on programs mentally challenged five year olds could write. Pathetic.
12
Name:
Anonymous
2007-10-04 16:45
`HailStorm'? More like `FailStorm' amirite?
13
Name:
Anonymous
2007-10-04 16:48
Alternatively, ShitStorm
14
Name:
Anonymous
2007-10-04 16:58
>>12
>>13
Yes, very much so. The truck of phail has collided with the truck of shit. Nasty mess it is.
15
Name:
Anonymous
2007-10-04 17:41
16
Name:
Anonymous
2007-10-04 23:59
can someone improve this??
package menuOperaciones;
import java.io.*;
public class MenuDeOperaciones
{
static int menu()
{
int opcion = 0;
do
{
System.out.println("=====0SELECCIONA======");
System.out.println("= 1.- Suma =");
System.out.println("= 2.- Resta =");
System.out.println("= 3.- Multiplicación =");
System.out.println("= 4.- División =");
System.out.println("= 5.- Salir =");
System.out.println("=====TU OPERACION=====");
opcion = Leer.datoInt();
}
while (opcion < 0 || opcion > 5);
return opcion;
}
public static void main (String[] args)
{
double datoa=0, datob=0, resultado=0;
int operacion;
try
{
while(true)
{
operacion = menu();
if(operacion < 5)
{
System.out.println("Ingresar Dato 1:"); datoa=Leer.datoDouble();
System.out.println("ingresar Dato 2:"); datob=Leer.datoDouble();
System.in.skip (System.in.available());
switch (operacion)
{
case 1: resultado = datoa + datob;
break;
case 2: resultado = datoa - datob;
break;
case 3: resultado = datoa * datob;
break;
case 4:
if (datob < 0 || datob > 0);
{
resultado = datoa / datob;
}
break;
}
System.out.println("Resultado = " + resultado);
}
else
System.out.println("Has salido del programa");
break;
}
}
catch(IOException ignorada) {}
}
}
17
Name:
Anonymous
2007-10-05 0:00
btw...
package menuOperaciones;
import java.io.*;
public class Leer
{
public static String dato()
{
String sdato = "";
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader flujoE = new BufferedReader(isr);
sdato = flujoE.readLine();
}
catch(IOException e)
{
System.err.println("Error: " + e.getMessage());
}
return sdato;
}
public static short datoShort()
{
try
{
return Short.parseShort(dato());
}
catch(NumberFormatException e)
{
return Short.MIN_VALUE;
}
}
public static int datoInt()
{
try
{
return Integer.parseInt(dato());
}
catch(NumberFormatException e)
{
return Integer.MIN_VALUE;
}
}
public static long datoLong()
{
try
{
return Long.parseLong(dato());
}
catch(NumberFormatException e)
{
return Long.MIN_VALUE;
}
}
public static float datoFloat()
{
try
{
Float f = new Float(dato());
return f.floatValue();
}
catch(NumberFormatException e)
{
return Float.NaN;
}
}
public static double datoDouble()
{
try
{
Double d = new Double(dato());
return d.doubleValue();
}
catch(NumberFormatException e)
{
return Double.NaN;
}
}
}
18
Name:
Anonymous
2007-10-05 5:53
>>16
can someone improve this??
Yes, port it to a decent language
19
Name:
Anonymous
2007-10-05 7:42
>>18
Limbo, the programming language for the Inferno OS. Of course, the original code is fairly useless, I assume it was homework.
implement Menuops;
include "sys.m";
sys: Sys;
include "bufio.m";
bufio: Bufio;
Iobuf: import bufio;
Menuops: module
{
init: fn();
data: fn(): string;
dataint: fn(): int;
databig: fn(): big;
datareal: fn(): real;
};
stdin: ref Iobuf;
init()
{
sys = load Sys Sys->PATH;
bufio = load Bufio Bufio->PATH;
stdin = bufio->fopen(sys->fildes(0), bufio->OREAD);
}
data(): string
{
return stdin.gets('\n');
}
dataint(): int
{
return int data();
}
databig(): big
{
return big data();
}
datareal(): real
{
return real data();
}
20
Name:
Anonymous
2007-10-05 8:34
>>19 here. Sorry, only ported half the program. Here's the whole thing.
implement Command;
include "sys.m";
sys: Sys;
include "draw.m";
include "bufio.m";
bufio: Bufio;
Iobuf: import bufio;
include "sh.m";
stdin: ref Iobuf;
init(nil: ref Draw->Context, nil: list of string)
{
sys = load Sys Sys->PATH;
bufio = load Bufio Bufio->PATH;
stdin = bufio->fopen(sys->fildes(0), bufio->OREAD);
quit := 0;
do {
op := menu();
(dataa, datab) := (0.0, 0.0);
if (op < 5) {
sys->print("Input data 1: ");
dataa = datareal();
sys->print("Input data 2: ");
datab = datareal();
}
result := 0.0;
case op {
1 =>
result = dataa + datab;
2 =>
result = dataa - datab;
3 =>
result = dataa * datab;
4 =>
if (datab != 0.0)
result = dataa / datab;
5 =>
sys->print("Has exited the program\n");
quit = 1;
}
if (op != 5)
sys->print("Result = %f\n", result);
} while (!quit);
}
menu(): int
{
opt := 0;
do {
sys->print(
"===== SELECT =====\n" +
"1. Add\n" +
"2. Subtract\n" +
"3. Multiply\n" +
"4. Divide\n" +
"5. Exit\n" +
"===== YOUR OPERATION =====\n");
opt = dataint();
} while (opt < 1 || opt > 5);
return opt;
}
data(): string
{
return stdin.gets('\n');
}
dataint(): int
{
return int data();
}
datareal(): real
{
return real data();
}
21
Name:
Anonymous
2007-10-05 8:40
ONE WORD, C:\HOMEWORK. THREAD OVER.
22
Name:
Anonymous
2007-10-05 9:48
Ha, how pathetic do you have to be to post your homework on a messageboard.
This fucking guy doesn't even realize he's just missing curly braces.
Fucking reject.
23
Name:
Anonymous
2007-10-05 9:49
Let's see if I can figure out where his school is.
24
Name:
Anonymous
2007-10-05 9:55
>>16
MEXICAN PROGRAMMER, RUN HE'LL INSTANTIATE MULTIPLE OBJECTS OF CHILDREN AND THROW THEM ACROSS THE BORDER! GTFO ! HE'S GONNA EAT A BURRITO111
25
Name:
Anonymous
2007-10-05 10:36
System.out.println("VIVA MEXICO CABRONES")
26
Name:
Anonymous
2009-03-06 9:40
The pages I posted your mom in THE NEXT ROOM?
27
Name:
Trollbot9000
2009-07-01 8:55
CONFUSING many people and languages the difference there is that it does not make what I think of Telnet?
29
Name:
Anonymous
2010-12-06 9:21
B a c k t o / b / , ` ` G N A A F a g g o t ' '
30
Name:
Anonymous
2010-12-17 1:27
Are you GAY ?
Are you a NIGGER ?
Are you a GAY NIGGER ?
If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!
31
Name:
Anonymous
2010-12-21 23:36