The Artima Developer Community
Sponsored Link

Java Answers Forum
need some help!!!!!!!!!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dude

Posts: 1
Nickname: elduderino
Registered: Apr, 2002

need some help!!!!!!!!! Posted: Apr 14, 2002 12:50 AM
Reply to this message Reply
Advertisement
i am pretty new to java and am racking my brain in the process. i have been getting a few errors on my program and cant figure them out. i posted my code below. is is unfinished, so it will look a little broken, but should still compile and run. the errors i am getting are:

non-static variable firstName/lastName cannot be referenced from a static context
firstName = name.substring( 0, whitespace);
lastName = name.substring( whitespace = 1);

cannot resolve symbol
showInfo( String name --its pointing to the beginning of String

incompatible types
found : void
required : java.lang.string
shows up in both :
String info = JOptionPane.showMessageDialog.... &
return JOptionPane.showMessage Dialog.... (in java:124)
i even asked my teacher about this error, and she couldnt tell me.

sorry i dont have any dukes to give out, i already gave them all away. but i would surely appreciate some help. i am racking my brain, and trying to grasp. it is coming, slowly, but surely. thanks!

import java.awt.*;
import javax.swing.*;

public class Program4 {

private String name;
private String lastName;
private String firstName;
private String address;
private String city;
private String state;
private String zip;
private String old;
private String income;
private String trek;
private String timeStamp;
private int zipCode;
private int age;
private int annIncome;
private int tracker = 0;
private int trackNum = 0;
private long stamp;

public static void main (String args [ ] )
{

String name, address, city, state, zip, old, income, trek, timeStamp;
int zipCode, age, annIncome, tracker = 0, trackNum = 0;
long stamp;

public Info ( String name, String firstName, String lastName, String address, String city, String state, String zip, String old,
String income, String trek, String timeStamp, int zipCode, int age, int annIncome,
int tracker, int trackNum, long stamp );

public Info ( ) {
name = " ";
lastName = " ";
firstName = " ";
address = " ";
city = " ";
state = " ";
zipCode = 00000;
age = 0;
annIncome = 0;
trek = " ";
stamp = " ";
tracker = 0;
trackNum = 0;
}

showNumberOfMembers( trackNum );
}

public String showInfo( String name, String address, String city, String state, String trek, String stamp, int zipCode, int age, int annIncome )
{
String output = "NAME : " + lastName + ", " + firstName +
"\nADDRESS : " + address +
"\nCITY : " + city +
"\nSTATE : " + state +
"\nZIP : " + zipCode +
"\nAGE : " + age +
"\nINCOME : " + annIncome +
"\nSTAR TREK MEMBER : " + trek +
"\nTIME STAMP : " + stamp;

String info = JOptionPane.showMessageDialog(null, output.toString( ), "MEMBER INFO", JOptionPane.INFORMATION_MESSAGE);
return info;
}

public String month ( int month )
{
switch (month){

case 1:
String out = "january";
break;
case 2:
out = "february";
break;
case 3:
out = "march";
break;
case 4:
out = "april";
break;
case 5:
out = "may";
break;
case 6:
out = "june";
break;
case 7:
out = "july";
break;
case 8:
out = "august";
break;
case 9:
out = "september";
break;
case 10:
out = "october";
break;
case 11:
out = "november";
break;
default:
out = "december";
break;

return out;

}
}

public static String showNumberOfMembers( int trackNum )
{
String output = "the number of members is : " + trackNum;
return JOptionPane.showMessageDialog(null, output, "# of members", JOptionPane.INFORMATION_MESSAGE);
}

public static void Switch( String name )
{
int whitespace;
name = SavitchIn.readLine( );
name = name.toUpperCase( );
whitespace = name.indexOf(" ");
firstName = name.substring( 0, whitespace);
lastName = name.substring( whitespace = 1);
}

public Info ( )
{
name = JOptionPane.showInputDialog("Enter member name.");
if ( name != " " ) {
name = JOptionPane.showInputDialog("Enter member name.");
address = JOptionPane.showInputDialog("Enter member street address.");
city = JOptionPane.showInputDialog("Enter city member is residing in.");
state = JOptionPane.showInputDialog("Enter state member is residing in.");
zip = JOptionPane.showInputDialog("Enter member zip code.");
zipCode = Integer.parseInt( zip );
old = JOptionPane.showInputDialog("Enter member zip code.");
age = Integer.parseInt( old );
income = JOptionPane.showInputDialog("Enter member's annual income.");
annIncome = Integer.parseInt( income );
trek = JOptionPane.showInputDialog("Enter member's favorite Star Trekkee.");
timeStamp = JOptionPane.showInputDialog("Enter today's date and time. \nIn the form -- 00-00-0000 00:00.00");
stamp = Long.parseLong( timeStamp );

tracker++;
trackNum += tracker;

showInfo( String name, String firstName, String lastName, String address, String city,
String state, String trek, long stamp, int zipCode, int age, int annIncome );

}
else
System.exit( 0 );
}

Topic: using jsp login page with ssl code sample Previous Topic   Next Topic Topic: How a request a key from my keyborad

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use