If you wish to get help with your code you better provide full code not just one class. Calculator class is missing.
By-the-way to insert code into post do not use inlinecode tag, but press hash sign "#" in the post bar or just simple type [ code] [/code] tags and place your code between these tags
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Update in code marked with red colour. There is no method nextChar for Scanner !
//Calculate Program
import java.util.Scanner;
public class Calculate
{
public static void main(String args[])
{
Calculator calc = new Calculator();// new Calculator
char selection;
char yesNo;
Scanner input = new Scanner(System.in);
//This is the priming question. It starts the calculator and
//should only run once.
System.out.printf("Do you want to perform a calculation now?\n");
System.out.printf("Select 'Y' for yes, or anything else for no.\n");
yesNo = input.nextLine().charAt(0);
//This while loop tests the initial answer. If user didn't enter 'Y'
//then loop and program should terminate
while(yesNo == 'Y' || yesNo == 'y')
{
//This section is where user selects type of operation
System.out.printf("What operation would you like to perform?\n");
System.out.printf("Enter '+' for add, '-' for subtract\n");
System.out.printf(" '*' for multiply '/' for divide\n");
selection = input.nextLine().charAt(0);
//This inner loop tests for operation type. User must enter valid
//response or loop won't end
while(selection != '+' && selection != '-' && selection != '*' && selection != '/')
{
System.out.printf("You need to enter a correct character.+-*/\n");
selection = input.nextLine().charAt(0);
}
//At this point, a valid operation should have been entered. This
//section should call appropriate method for the operation
if(selection == '+')
calc.add();
if(selection == '-')
calc.sub();
if(selection == '*')
calc.mult();
if(selection == '/')
calc.div();
//This section is the end of the first while loop. It gives user
//the option to exit or perform another operation.
System.out.printf("Do you want to perform another calculation\n");
System.out.printf("Enter 'Y' for yes, or anything else for no.\n");
yesNo = input.nextLine().charAt(0);
}
}
}
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Man!!!!
Why so many posts about something to which you have solution in my post?
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
Read the error in its entirety, especially the name of the class it reports and the line number. Try to figure out why the compiler cannot see that class.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
I've not used JECreator, but did you perhaps set a main class for your project somewhere? A properties window or some such? It sounds as if it still thinks that is your main class.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Just compile and run it from the command line.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847