I am in my second week of java programing and after reading the chapters I seem to be a bit lost this weeks assingment is • Create a non-GUI-based Java application that calculates the payroll for a department in an organization. The application should display text that requests the user input for the name of the department, the number of employees in the department, and the average salary for the employees in the department. The number of employees in the department should be a whole number, and the average salary for the employees should be a real number. The application should then print out the name of the department and the total department payroll for all of the employees in the department (number of employees times the average salary for each employee). The total department payroll amount should be a real number. In the printout, display the dollar symbol ($) to the left of the total department payroll amount and format the amount to display currency.
I was doing good but now I cant seem to get rid of a cant find symbol error in my code. Just wondering what I am doing wrong and how can I make sure not to do this next time. My code is below.

//Payroll.java
//Calculate payroll by multiplying number of employees by average salary
import java.util.Scanner; // program uses class scaner

public class Payroll
{
	// main method begins execution of java application
	public static void main( String args[] )
	{
		// create Scanner to gain input from comand window
		Scanner input = new Scanner( System.in );

		char Department_name; // Name of the department
		int Employee_total; // First number to be multiplied
		int Avg_salary; // Second number to be multiplied
		int Department_payroll; // Product of number1 and number2
	
		System.out.print( "Enter name of department" ); // promt
		Department_name = input.nextChar(); //read department name entered by user

		System.out.print( "Enter number of employees must be whole number" ); // promt
		Employee_total = input.nextInt(); // read first number entered by user

		System.out.print( "Enter average salary of employee must be whole number" ); 

// promt
		Avg_salary = input.nextInt(); // read second number entered by user

		Department_payroll = Employee_total * Avg_salary; // multiply numbers

		System.out.printf( "Dapartment name" ); //display department name
		System.out.printf( "Payroll is *d\n", Department_payroll ); // display 

department name and total payroll

	} // end main
} // end class

Recommended Answers

All 3 Replies

I am sorry The error is presenting itself on line 19 cannot find symbol, method Char(),

Do you mean cannot find symbol, method nextChar()?
If so, check out the API for Scanner - there is no nextChar() method in Scanner (there also isn't a Char() method either)
A char is a single character, and I guess your department names are longer than 1 char, so you probably want to use nextLine()

Do you mean cannot find symbol, method nextChar()?
If so, check out the API for Scanner - there is no nextChar() method in Scanner (there also isn't a Char() method either)
A char is a single character, and I guess your department names are longer than 1 char, so you probably want to use nextLine()

Thank you I will give it a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.