I'm new to Java and have taken a course at CU Denver in Java
Programming. The course outline states (ironically) that you must
have W95 or a Mac to take the course. I have entered it using
Linux. All has been fine up till I turned in my first code. The
following code compiles and runs on my machine without error but
the instructor stated that when he compiled and ran my code, he
got an error.
"I get an IO exception on any input to sreport.java. Let
me know if you are seeing a different behavior."
Why would this code work fine on Linux and not on his Mac?
Could someone be so kind as to compile and confirm my results?
(I'm unsure of what version he is running.)
My version is JDK_1.1.5 on RH5.0 using kernal 2.0.33
//////////////////sreport.java/////////////////////
// a cheesy program to demonstrate IO //
// Program will add sales items and calculate //
// Salesman's commistion //
import java.io.*;
public class sreport {
public static void main(String args[]) throws IOException
{
double _total=200; //var init to base salary
final double _PC=0.09; //percent commission
final double _A=239.99*_PC;
final double _B=129.75*_PC; //commission on cost of
final double _C=99.95*_PC; //each Item
final double _D=350.89*_PC; //itemcost * percent-commission
char prod=0;
do
{
System.out.println("Enter the Product Sold ( A->D ). X to Exit");
prod=(char)System.in.read();
switch(prod)
{
case'a':case'A':
_total+=_A;
break;
case'b':case'B':
_total+=_B;
break;
case'c':case'C':
_total+=_C;
break;
case'd':case'D':
_total+=_D;
}
System.in.skip(1); //remove nl
}while(prod!='x'&&prod!='X');
System.out.println("Total Weekly Pay is $"+_total);
}
}
--
Glenn Valenta Engineering http://www.coloradostudios.com
[EMAIL PROTECTED] http://ouray.cudenver.edu/~gavalent/
[EMAIL PROTECTED] <-main mail account