I am extremely new to Java, I am taking a class and below is our homework assignment for this week. I have emailed my teacher but have not received a response yet, so I am coming to you experts.
I need to build this program to write to a file using a java applet window that has Name, Address, GPA and Age, below is the information that the instructor provided, can someone help me learn this?
thanks.
Code:
// HERE'S YOUR TOOLKIT USE IT !!!!
/* i = Integer.parseInt(str);
if(i==-1) break;
l = Long.parseLong(str);
f = Float.valueOf(str).floatValue();
d = Double.valueOf(str).doubleValue();
b =Boolean.valueOf(str).booleanValue();
// as you will see you do the booleans
// like the floats and doubles !!!
// c= str[0];// nope this is C or C++
c = str.charAt(0);// correct way to read a cahracter in Java
// zero is the first character of the string object.
System.out.println(i+" "+l+" "+f+" "+d+ " "+ c);
*/
import java.io.*;
class Emprec {
String name;
String address;
// double gpa;
// int age;
Emprec (String name,String address)
{
try{
this.name=name;
this.address=address;
} catch(NumberFormatException errmsg)
{
System.out.println("Invalid format"+ errmsg);
this.name = "";
// this.gpa = 0.0;
// this.age = 0;
}//catch
}//Emprec constructor !!!!
String junk () {return("Happy Birthday !!!");}
public String toString()
{
return
("\n your name is "+ name+
"\n your address is "+ address+junk());
}//toString
// see if you can get the boolean to load from a text file.
// what's missing ????
//methods !!!!
// constructors !!!
}// Emprec
class ParseEmpSolHW
{
public static void main(String args[])
throws IOException
{
BufferedReader inData = new BufferedReader(new InputStreamReader(System.in));
// create strings for the input data for the Emprec object
String str_name;
String str_address;
for(;;){