All I am trying to do is find a way the user inputs their name and then it simple displays it when asked too. Does anyone have any suggestions?
prompt user to input name
code
code
code
system.out----name
system.out----$$$$
system.out----Employee Type
etc
etc
5 replies to this topic
#1
Posted 25 March 2011 - 06:27 PM
|
|
|
#2
Posted 26 March 2011 - 02:43 AM
Scanner class
String input = scanner.next();
out.print(input);
String input = scanner.next();
out.print(input);
OBDMobile http://sites.google....te/obdiimobile/
#3
Posted 26 March 2011 - 11:15 AM
Ok, I tried for a while but my IDE was throwing an error message.
All I want to do is allow the user to type their name and then after they input additional data at the end of the program print the name they have type in the beginning. You might have already answered this but I am still lost.
All I want to do is allow the user to type their name and then after they input additional data at the end of the program print the name they have type in the beginning. You might have already answered this but I am still lost.
#4
Posted 26 March 2011 - 11:30 AM
Post what you have coded so far.
#5
Posted 26 March 2011 - 11:52 AM
Here it is......
public class XXX {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int HE = 1, PE = 2, SA = 3;
int employeeType = 0;
double weekly_hourly_Sal= 0,hoursWorked = 0;
double salaryDue =0;
double numberPieces = 0,wage_Per_peice = 0;
double items_sold = 0, baseweekly_Salary = 0;
double employeeCommission = 0,commissionDue = 0;
int week_Number = 0;
double item_Price = 0, final_SA_wages;
String name =input.nextLine();
System.out.println("Please enter name:)");
name = input.nextLine();
System.out.println("Employee Type: HE (1), PE (2), SA (3)");
employeeType = input.nextInt();
System.out.println("Please enter week number: ");
week_Number =input.nextInt();
while ( employeeType == 1){
System.out.println("Please enter # hours worked: ");
hoursWorked = input.nextDouble();
if ( hoursWorked > 70){
System.out.println("Hours need be less than 71 weekly: ");
continue;
}
if ( week_Number < 0 && week_Number > 52){
System.out.println("Please enter number between 1-52: " );
}
System.out.println("Please enter hourly pay: ");
weekly_hourly_Sal = input.nextDouble();
salaryDue = weekly_hourly_Sal * hoursWorked;
System.out.println("Weeks Pay: " + salaryDue);
System.out.println();
System.out.println("ABC Company");
System.out.println("=============================");
System.out.println("Week #:" + week_Number);
System.out.println("Employee name:" + name );
System.out.println("Employee type:" + employeeType );
System.out.println();
System.out.println("Hourly Salary:" + weekly_hourly_Sal);
System.out.println("Number Hours Worked:" + hoursWorked) ;
System.out.println("Salary Due:" + salaryDue);
System.out.println("=============================");
System.exit( 0 );
}
while ( employeeType == 2){
if ( week_Number < 0 && week_Number > 52){
System.out.println("Please enter number between 1-52: " );
}
System.out.println("Please enter week number: ");
week_Number =input.nextInt();
System.out.println("Please enter # of pieces produced: ");
numberPieces = input.nextDouble();
System.out.println("Please wage per piece: ");
wage_Per_peice = input.nextDouble();
salaryDue = numberPieces * wage_Per_peice;
System.out.println("Weeks Pay: " + salaryDue);
System.out.println();
System.out.println("ABC Company");
System.out.println("=============================");
System.out.println("Week #:" + week_Number);
System.out.println("Employee name:" );
System.out.println("Employee type:" + employeeType );
System.out.println();
System.out.println("Weekly Pieces Produced:" + numberPieces);
System.out.println("Wages Per Piece:" + wage_Per_peice) ;
System.out.println("Salary Due:" + salaryDue);
System.out.println("=============================");
System.exit( 0 );
}
while ( employeeType == 3){
if ( week_Number < 0 && week_Number > 52){
System.out.println("Please enter number between 1-52: " );
}
System.out.println("Please enter week number: ");
week_Number =input.nextInt();
System.out.println("Please enter number of items sold: ");
items_sold = input.nextDouble();
System.out.println("Please enter price of each item: ");
item_Price = input.nextDouble();
System.out.println("Please weekly base salary: ");
baseweekly_Salary = input.nextDouble();
System.out.println("Please enter your commision: ");
employeeCommission= input.nextDouble();
salaryDue = (items_sold * item_Price);
final_SA_wages = (salaryDue *employeeCommission)+ baseweekly_Salary;
System.out.println();
System.out.println("Weeks Pay: " + commissionDue);
System.out.println("ABC Company");
System.out.println("=============================");
System.out.println("Week #:" + week_Number);
System.out.println("Employee name:" );
System.out.println("Employee type:" + employeeType );
System.out.println();
System.out.println("Weekly Base Salary:" +baseweekly_Salary) ;
System.out.println("Number of items sold:" + items_sold );
System.out.println("Salary Due:" + final_SA_wages);
System.out.println("=============================");
System.exit( 0 );
}
}
}
#6
Posted 26 March 2011 - 01:46 PM
Thanks for all the help I was able to get it figured out. If you would like to see the final product just let me know! You guys are awesome!!!!!!!:thumbup1:
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









