Bracket expected.... not sure where [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
So I'm doing an assignment on modular programing and here Im getting a bracket expected error. Here is the code:
import java.util.*;
public class stlab09
{
public static void main (String args[])
{
System.out.println("\nLAB09 90 POINT VERSION\n\n");
enterData();
computeGPA();
displayData();
}
static String lGrade1;
static String lGrade2;
static String lGrade3;
static String lGrade4;
static int cHours1;
static int cHours2;
static int cHours3;
static int cHours4;
static String dummy;
public static double gpa;
public static void enterData()
{
Scanner in = new Scanner(System.in);
System.out.print("Enter course 1 Grade ===>> ");
lGrade1 = in.nextLine();
System.out.print("enter course 1 Hours ===>> ");
cHours1 = in.nextInt(); dummy = in.nextLine();
System.out.print("Enter course 2 Grade ===>> ");
lGrade2 = in.nextLine();
System.out.print("enter course 2 Hours ===>> ");
cHours2 = in.nextInt(); dummy = in.nextLine();
System.out.print("Enter course 3 Grade ===>> ");
lGrade3 = in.nextLine();
System.out.print("enter course 3 Hours ===>> ");
cHours3 = in.nextInt(); dummy = in.nextLine();
System.out.print("Enter course 4 Grade ===>> ");
lGrade4 = in.nextLine();
System.out.print("enter course 4 Hours ===>> ");
cHours4 = in.nextInt(); dummy = in.nextLine();
}
public static void computeGPA()
{
Grades.gradeValue();
Grades.courseValue();
Grades.getGPA();
}
public static void displayData()
{
System.out.println();
System.out.println("Course1 Grade: " + lGrade1 + " Course1 Credit Hours: " + cHours1);
System.out.println("Course2 Grade: " + lGrade2 + " Course2 Credit Hours: " + cHours2);
System.out.println("Course3 Grade: " + lGrade3 + " Course3 Credit Hours: " + cHours3);
System.out.println("Course4 Grade: " + lGrade4 + " Course4 Credit Hours: " + cHours4);
System.out.println();
System.out.println("Current GPA: " + gpa);
}
}
public class Grades() ***<<<<<<<<<<<<<<<<<< bracket expected here***
{
public static void gradeValue()
{
int value = 0;
char lg1 = lGrade1.charAt(0);
switch(lg1)
{
case 'A': value = 4; break;
case 'B': value = 3; break;
case 'C': value = 2; break;
case 'D': value = 1; break;
case 'F': value = 0; break;
}
int gVal1 = value;
char lg2 = lGrade2.charAt(0);
switch(lg2)
{
case 'A': value = 4; break;
case 'B': value = 3; break;
case 'C': value = 2; break;
case 'D': value = 1; break;
case 'F': value = 0; break;
}
int gVal2 = value;
char lg3 = lGrade3.charAt(0);
switch(lg3)
{
case 'A': value = 4; break;
case 'B': value = 3; break;
case 'C': value = 2; break;
case 'D': value = 1; break;
case 'F': value = 0; break;
}
int gVal3 = value;
char lg4 = lGrade4.charAt(0);
switch(lg4)
{
case 'A': value = 4; break;
case 'B': value = 3; break;
case 'C': value = 2; break;
case 'D': value = 1; break;
case 'F': value = 0; break;
}
int gVal4 = value;
}
public static void courseValue()
{
int cVal1 = gVal1 * cHours1;
int cVal2 = gVal2 * cHours2;
int cVal3 = gVal3 * cHours3;
int cVal4 = gVal4 * cHours4;
}
public static void getGPA()
{
double totalValue = cVal1 + cVal2 + cVal3 + cVal4;
double totalHours = cHours1 + cHours2 + cHours3 + cHours4;
double gpa = totalValue / totalHours;
}
}
So yeah I need some help figuring this out because I'm kinda going crazy about it. The expected program is supposed to use keyboard input of letter grades and course hours to compute GPA and grades. The assignment is to get that outcome but the main method must stay exactly as is, and almost every method was provided to me and i just had to organize them.

You have declared the inner class Grades as if it's a method (you added () onto the end of it), look at how the class stlab09 is declared, there aren't any ().

Related

Another way except of UserInput

I would like to know how to do this with another way except of userinput? I don't want to write the values I want to do this the user
Calculate calculation = new Calculate();
int sum = calculation.sum(2, 5);
int testSum = 7;
#Test
public void testSum() {
System.out.println("#Test sum(): " + sum + " = " + testSum);
assertEquals(sum, testSum);
}
}
I guess the following might help:
public void test() {
int number1 = 0;
int number2 = 0;
int expected = 0;
System.out.println("Enter first number");
int state = 0;
Scanner scanner = new Scanner(System.in);
String input = "";
while(!input.equals("E")) {
input = scanner.nextLine();
input = input.toUpperCase();
if (!input.equals("") && Character.isDigit(input.charAt(0))){
switch(state) {
case 0:
number1 = Integer.parseInt(input);
System.out.println("Enter second number");
break;
case 1:
number2 = Integer.parseInt(input);
System.out.println("Enter expected result");
break;
case 2:
expected = Integer.parseInt(input);
System.out.println("Result: " + (number1 + number2) +
" | Expected: " + expected + System.lineSeparator());
System.out.println("Enter first number");
state = -1;
break;
default:
break;
}
state++;
}
}
scanner.close();
System.out.println("Exiting");
}

Calculator in Java: How to return to the main menu?

I've writter a calculator program in Java, after a user is done with work,
I want this to happen:
i'll ask if he wants to do more operations, if yes, the program should return to choice input. If no, break the program.
What lines should I add to the code? This is my calc program:
import java.util.*;
class calc
{
public static void main(String ar[])
{
char choice;
Scanner in = new Scanner(System.in);
System.out.println("WELCOME TO SHREYDAN'S CALC 1.0");
System.out.println(" ");
System.out.println("YOU CAN DO THE FOLLOWING:");
System.out.println("+: ADDITION");
System.out.println("-: SUBTRACTION");
System.out.println("*: PRODUCT");
System.out.println("/: QUOTIENT");
System.out.println("#: SQUARE ROOT");
System.out.println("^: POWER");
System.out.println("$: ROUND OFF");
System.out.println("!: FACTORIAL");
System.out.println(" ");
System.out.println("ENTER CHOICE");
choice=in.next().charAt(0);
switch(choice)
{
case '+':
System.out.println("ENTER 2 NUMBERS, USER");
double a=in.nextDouble();
double b=in.nextDouble();
System.out.println("SUM = "+(a+b));
break;
case '-':
System.out.println("ENTER 2 NUMBERS, USER");
double c=in.nextDouble();
double d=in.nextDouble();
System.out.println("SUBTRACTING "+d+" FROM "+c+" ... DIFFERENCE = "+(c-d));
break;
case '*':
System.out.println("ENTER 2 NUMBERS, USER");
double e=in.nextDouble();
double f=in.nextDouble();
System.out.println("PRODUCT = "+(e*f));
break;
case '/':
System.out.println("ENTER 2 NUMBERS, USER");
double g=in.nextDouble();
double h=in.nextDouble();
System.out.println("DIVIDING "+g+" BY "+h+" = "+(g/h));
break;
case '#':
System.out.println("ENTER NO. FOR SQAURE ROOT:");
double sqrt=in.nextDouble();
System.out.println("SQUARE ROOT OF "+sqrt+" = "+Math.sqrt(sqrt));
break;
case '^':
System.out.println("ENTER BASE, USER");
double base=in.nextDouble();
System.out.println("ENTER POWER, USER");
double power=in.nextDouble();
System.out.println(base+" RAISED TO POWER "+power+" = "+Math.pow(base,power));
break;
case '$':
System.out.println("ENTER DECIMAL VALUES TO ROUND OFF");
double deci=in.nextDouble();
System.out.println("THE NEAREST ROUND OFF = "+Math.round(deci));
break;
case '!':
System.out.println("ENTER A NO. FOR FACTORIAL:");
int fact=in.nextInt();
int factorial=1;
for(int i=fact; i>=1;i--)
factorial=factorial*i;
System.out.println(fact+"! = "+factorial);
break;
default:
System.out.println("WRONG CHOICE USER");
}
}
}
while loops are your best bet for this type of problem, just think of a condition which the user can choose to toggle the boolean condition.
for example if the user chooses no on the "continuing of operations" choice, then toggle the boolean to false and exit the while loop to end the program.
You need to wrap the program logic in a loop.
Try using a while loop
public static void main(String args[])
{
boolean doContinue = true;
while(doContinue){
char choice;
Scanner in = new Scanner(System.in);
//program logic
//when the user enters a command to end
// set continue=false
}
}
Maybe put the entire program inside a while loop with a continue to run bool condition which could be set false when they want to quit
You can try the following:
import java.util.*;
class calc {
public static void main(String ar[]) {
char choice;
Scanner in = new Scanner(System.in);
System.out.println("WELCOME TO SHREYDAN'S CALC 1.0");
System.out.println(" ");
boolean loop = true;
while (loop) {
System.out.println("YOU CAN DO THE FOLLOWING:");
System.out.println("+: ADDITION");
System.out.println("-: SUBTRACTION");
System.out.println("*: PRODUCT");
System.out.println("/: QUOTIENT");
System.out.println("#: SQUARE ROOT");
System.out.println("^: POWER");
System.out.println("$: ROUND OFF");
System.out.println("!: FACTORIAL");
System.out.println(" ");
System.out.println("ENTER CHOICE");
choice = in.next().charAt(0);
switch (choice) {
case '+':
System.out.println("ENTER 2 NUMBERS, USER");
double a = in.nextDouble();
double b = in.nextDouble();
System.out.println("SUM = " + (a + b));
break;
case '-':
System.out.println("ENTER 2 NUMBERS, USER");
double c = in.nextDouble();
double d = in.nextDouble();
System.out.println("SUBTRACTING " + d + " FROM " + c + " ... DIFFERENCE = " + (c - d));
break;
case '*':
System.out.println("ENTER 2 NUMBERS, USER");
double e = in.nextDouble();
double f = in.nextDouble();
System.out.println("PRODUCT = " + (e * f));
break;
case '/':
System.out.println("ENTER 2 NUMBERS, USER");
double g = in.nextDouble();
double h = in.nextDouble();
System.out.println("DIVIDING " + g + " BY " + h + " = " + (g / h));
break;
case '#':
System.out.println("ENTER NO. FOR SQAURE ROOT:");
double sqrt = in.nextDouble();
System.out.println("SQUARE ROOT OF " + sqrt + " = " + Math.sqrt(sqrt));
break;
case '^':
System.out.println("ENTER BASE, USER");
double base = in.nextDouble();
System.out.println("ENTER POWER, USER");
double power = in.nextDouble();
System.out.println(base + " RAISED TO POWER " + power + " = " + Math.pow(base, power));
break;
case '$':
System.out.println("ENTER DECIMAL VALUES TO ROUND OFF");
double deci = in.nextDouble();
System.out.println("THE NEAREST ROUND OFF = " + Math.round(deci));
break;
case '!':
System.out.println("ENTER A NO. FOR FACTORIAL:");
int fact = in.nextInt();
int factorial = 1;
for (int i = fact; i >= 1; i--)
factorial = factorial * i;
System.out.println(fact + "! = " + factorial);
break;
default:
System.out.println("WRONG CHOICE USER");
}
System.out.println("Want to calculate more?Y/N");
loop = in.next().charAt(0) == 'Y';
}
}
}

GPA array calculation error

I am having issues with my gpa program where I have to use two arrays to store a grade and it's credits and calculate the gpa. So far, everything else seems to be working except the gpa wont calculate correctly and I am not sure what I am missing (probably simple).
My code thus far is:
Gpa class:
import java.util.*;
public class Gpa{
int[] credits = new int[4];
String[] grades = new String[4];
private int numCourses;
private int maxCourses;
private int sumOfCourses;
private int sumCredits;
private int sumPoints;
int newCredits;
int totalSum = 0;
int total = 0;
public Gpa(int noCourses){
maxCourses = noCourses;
numCourses = 0;
}
public void addCourse(int _newCredits, String newGrade){
for (int i=0; i<maxCourses; i++){
newCredits = _newCredits;
credits[i] = newCredits;
}
for (int i=0; i<maxCourses; i++){
grades[i] = newGrade;
}
switch (newGrade) {
case "A":
case "a":
newGrade = "4";
break;
case "B":
case "b":
newGrade = "3";
break;
case "C":
case "c":
newGrade = "2";
break;
case "D":
case "d":
newGrade = "1";
break;
case "F":
case "f":
newGrade = "0";
break;
}
sumPoints = sumPoints + (newCredits * Integer.parseInt(newGrade));
numCourses++;
}
public double calcGPA(){
for (int i=0; i<maxCourses; i++){
sumCredits = sumCredits + newCredits;
}
double gpa = (double)sumPoints/sumCredits;
return gpa;
}
} // end class
The tester class:
import java.util.Scanner;
public class GpaTestEx2
{
public static void main (String[] args)
{
//declarations
Scanner in = new Scanner(System.in); //input object
int numCourses; //number of courses - can be changed
int credits; //number of credits for a course
String grade; //grade for course
//read in number of courses
System.out.print("Enter number of courses: ");
numCourses = in.nextInt();
//create Gpa object to hold specified number of courses
Gpa myGPA = new Gpa(numCourses);
//read in all courses and add course information to Gpa object
for (int k=0; k<numCourses; k++)
{
System.out.print("Enter credits for course " + (k+1) + ": ");
credits = in.nextInt();
System.out.print("Enter grade for course " + (k+1) + ": ");
grade = in.next();
myGPA.addCourse(credits, grade);
}
//print results
System.out.println();
System.out.printf("GPA is %4.2f%n", myGPA.calcGPA( ));
} //end main
}
When I enter the course credits and grade it does not calculate the gpa correctly. For example, if the user input says there are 2 courses with one class having 4 credits with a grade of A and the other having 3 credits with a grade of B. I get a gpa of around 4.17 when it should be 3.57.
Any help would be great, I may or may not be missing something simple.
It seems like you are indexing into every element in your array every time someone inserts a value. We only need to change one element when a new grade is added. GPA class:
public class Gpa {
private int[] credits;
private String[] grades;
private int currentGrade;
public Gpa(int numGrades) {
credits = new int[numGrades];
grades = new String[numGrades];
currentGrade = 0;
}
public void addGrade(String letterGrade, int credit) {
grades[currentGrade] = letterGrade;
credits[currentGrade] = credit;
currentGrade = currentGrade + 1;
}
public double getGpa() {
double totalPoints = 0;
double totalWeight = 0;
for (int i = 0; i < currentGrade; i++) {
totalPoints = totalPoints + (letterToGpa(grades[i]) * credits[i]);
totalWeight = totalWeight + credits[i];
}
return totalPoints / totalWeight;
}
private double letterToGpa(String letter) {
char first = letter.toUpperCase().charAt(0);
switch (first) {
case 'A':
return 4.0;
case 'B':
return 3.0;
case 'C':
return 2.0;
case 'D':
return 1.0;
}
return 0.0;
}
}
The test class should work fine now:
public static void main(String[] args) {
Scanner in = new Scanner(System.in); //input object
int numCourses; //number of courses - can be changed
int credits; //number of credits for a course
String grade; //grade for course
//read in number of courses
System.out.print("Enter number of courses: ");
numCourses = in.nextInt();
//create Gpa object to hold specified number of courses
Gpa t = new Gpa(numCourses);
//read in all courses and add course information to Gpa object
for (int k=0; k<numCourses; k++)
{
System.out.print("Enter credits for course " + (k+1) + ": ");
credits = in.nextInt();
System.out.print("Enter grade for course " + (k+1) + ": ");
grade = in.next();
t.addGrade(grade, credits);
}
//print results
System.out.println();
System.out.printf("GPA is %4.2f%n", t.getGpa());
}
Just want to note that this clearly isn't the best way of doing this, nor does it follow Object Oriented patterns very well, but the OP's assignment requires we only use one class, etc.

How to read multiple Strings off the same line via the scanner Without Split();

.split() Method is NOT Allowed
I was got some help earlier from a helpful guy! I was just wondering if anyone could help me modify this a little bit more,
The code is meant for an assignment and It is based on the input from the scanner. It has two other classes but this is the one of interest.
The code is working at the moment, however The things that have to be input are things like **U5, D10** etc. That works fine. However I need the code to be able to read multiple String off one one line whilst seperating them like they are now. Like say for example **D10 U5 L4**, all from one line for just one player out of two. The code at the moment is not recognizing it as one line and instead if assigning the second typed thing to the second player.
Any tips?
Thanks
import java.util.Scanner;
class Asgn2
{
public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
Player me = new Player("Player1");
Player opponent = new Player("player2");
int startingLoop = 0;
String strA;
int turn =1;
System.out.print("How many turns will the game have: ");
int turnsInGame = scan.nextInt();
System.out.print("How many moves does each player have each turn: ");
int numberOfTurns = scan.nextInt();
for(int i = turnsInGame; startingLoop < i; startingLoop++)
{
System.out.print("Turn " + turn++ + "\n");
System.out.print("Player 1 what are your " + numberOfTurns + " move(s): ");
String userInput = scan.next();
System.out.print("Player 2 what are your " + numberOfTurns + " move(s): ");
String userInputOne = scan.next();
for (int j = 0; j < userInput.length() - 1; j++)
{
char letter = userInput.charAt(j);
String num = "";
for(int k= j + 1; k < userInput.length(); k++)
{
j++;
if(userInput.charAt(k)!=' ')
{
num+=userInput.charAt(k);
}
else
{
break;
}
}
int integer = Integer.parseInt(num + "");
strA = Character.toString(letter);
switch(strA) //For player oneChooses which value to add or subtract from based on what is input.
{
case "U":
me.move(moveSteps.UP , integer);
break;
case "D":
me.move(moveSteps.DOWN, integer);
break;
case "L":
me.move(moveSteps.LEFT, integer);
break;
case "R":
me.move(moveSteps.RIGHT, integer);
break;
}
//Player 2
for (int playerTwo = 0; playerTwo < userInputOne.length() - 1; playerTwo++)
{
char letterTwo = userInputOne.charAt(0);
String numTwo = "";
String strB = Character.toString(letterTwo);
for(int m= playerTwo + 1; m<userInput.length(); m++)
{
playerTwo++;
if(userInputOne.charAt(playerTwo)!=' ')
{
numTwo+=userInputOne.charAt(playerTwo);
}
else
{
break;
}
}
int stepsMoved = Integer.parseInt(numTwo + "");
switch(strB) //For player two
{
case "U":
opponent.move(moveSteps.UP , stepsMoved);
break;
case "D":
opponent.move(moveSteps.DOWN, stepsMoved);
break;
case "L":
opponent.move(moveSteps.LEFT, stepsMoved);
break;
case "R":
opponent.move(moveSteps.RIGHT, stepsMoved);
break;
}
}
}
System.out.print(me);
System.out.print(opponent);
}
}
}
Once you assign the input to a String, use the .split() method to split the string into an array. To use the .split(), put in the character you want to split it with. In this case a space. For example use this for your current project: .split(" "). Once you split it, you can access it just like any array.
Update:
first use the .nextLine() and assign it to a temporary string variable. Then
you can create another scanner and put a string in. For example:
Scanner sc = new Scanner(YOUR TEMPORARY VARIABLE);
you can now use the .next() to get individual strings.
Here is the Asgn2 class
import java.util.Scanner;
public class Asgn2 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("What is your name player 1: ");
String p1name = scan.nextLine();
System.out.print("What is your name player 2: ");
String p2name = scan.nextLine();
Player p1 = new Player(p1name);
Player p2 = new Player(p2name);
System.out.print("How many turns will the game have: ");
int numTurns = scan.nextInt();
System.out.print("How many moves does each player have each turn: ");
int numMoves = scan.nextInt();
for (int turn = 1; turn <= numTurns; turn++) {
System.out.println("----------------");
System.out.println("Turn number " + turn);
System.out.println("----------------");
for (int player = 1; player <= 2; player++) {
System.out.print("Player " + player + " what are your " + numMoves + " move(s): ");
for(int move=1;move<=numMoves;move++){
String currMove = scan.next();//splits at space;
char dir = currMove.charAt(0);//gets dir
String temp="";
for(int index=1;index<currMove.length();index++){
temp+=currMove.charAt(index);
}
int dist = Integer.parseInt(temp);
if(player==1){
p1.move(dir, dist);
}else if(player==2){
p2.move(dir, dist);
}
}
System.out.println("Player 1 is at " + p1.getPos() + " and Player 2 is at " + p2.getPos());
System.out.println();
}
}
}
}
And here is the Player class
public class Player {
private String name;
private int locX = 0;
private int locY = 0;
public Player(String name) {
this.name = name;
}
public void move(char dir, int numSteps) {
switch (dir) {
case 'U':
locY += numSteps;
break;
case 'D':
locY -= numSteps;
break;
case 'L':
locX -= numSteps;
break;
case 'R':
locX += numSteps;
break;
}
}
public String getPos() {
return "(" + locX + ", " + locY + ")";
}
public String getName() {
return name;
}
}
And before anyone goes and says that posting blocks of code does not help OP, I am in a chatroom with him in which I explain this stuff, so dont hate :)
call the method .nextLine() instead of .next(). I think that should solve your problem.

Java error: method in class cannot be applied to given types

I am just trying to call the methods to the main for each switch when it happens, but i just get the error message everytime i try to call any methods, not trying to return anything. ex. if the user enters a or A i want to call the add method to main
public static void main(String[] args)
{
char character;
Scanner keyboard = new Scanner(System.in);
while (character != 'E' || character != 'e')
{
System.out.println(" A:Addition \n S:Subtraction \n M:Multiplication \n D:Division \n R:Modulus \n E:exit");
switch (character)
{
case 'a':
case 'A':
System.out.println("your choice A");
add();
break;
case 's':
case 'S':
System.out.println("your choice S");
subtraction();
break;
case 'm':
case 'M':
System.out.println("your choice M");
multiplication();
break;
case 'd':
case 'D':
System.out.print("your choice D");
division();
break;
case 'r':
case 'R':
System.out.println("your choice R");
modulus();
break;
default:
System.out.println("Error: please enter a valid letter");
break;
}
}
}
public static void add(Scanner keyboard)
{
int a,b;
//get integer 1
System.out.println("enter integer 1");
a = keyboard.nextInt ();
//get integer 2
System.out.println("enter integer 2");
b = keyboard.nextInt();
int total = a + b;
System.out.println(a + "plus" + b + "is" + total );
}
public static void subtraction(Scanner keyboard)
{
int a,b;
//get integer 1
System.out.println("enter integer 1");
a = keyboard.nextInt ();
//get integer 2
System.out.println("enter integer 2");
b = keyboard.nextInt();
int total = a-b;
System.out.println(a + "minus" + b + "is " + total);
}
public static void multiplication(Scanner keyboard)
{
int a,b;
//get integer 1
System.out.println("enter integer 1");
a = keyboard.nextInt ();
//get integer 2
System.out.println("enter integer 2");
b = keyboard.nextInt();
int total = a*b;
System.out.println(a + "times" + b + "is " + total);
}
public static void division(Scanner keyboard)
{
int a,b;
//get integer 1
System.out.println("enter integer 1");
a = keyboard.nextInt ();
//get integer 2
System.out.println("enter integer 2");
b = keyboard.nextInt();
int total = a/b;
System.out.println(a + "divided" + b + "is " + total);
}
public static void modulus(Scanner keyboard)
{
int a,b;
//get integer 1
System.out.println("enter integer 1");
a = keyboard.nextInt ();
//get integer 2
System.out.println("enter integer 2");
b = keyboard.nextInt();
int total= a%b;
System.out.println(a + "modulus" + b + "is " + total);
System.out.println("The program is terminating");
}
}
you're calling the method but you didn't include an argument
take a look at this.
public static void add(Scanner keyboard)
you have an argument, so you must include an argument when calling this method
so
you must call the method like this.
add(keyboard);
You have defined the method which takes Scanner as argument but you are calling the methods with no args.
All the method you are using are supposed to receive a Scanner object while you pass no argument.
For example you call add(); while it signature is
public static void add(Scanner keyboard)
Which is why you get the error.
Instead, use add(keyboard) and repeat the same for substraction, multiplication, division and modulus methods.
So that your switch would now look like
switch (character) {
case 'a':
case 'A':
System.out.println("your choice A");
add(keyboard);
break;
case 's':
case 'S':
System.out.println("your choice S");
subtraction(keyboard);
break;
case 'm':
case 'M':
System.out.println("your choice M");
multiplication(keyboard);
break;
case 'd':
case 'D':
System.out.print("your choice D");
division(keyboard);
break;
case 'r':
case 'R':
System.out.println("your choice R");
modulus(keyboard);
break;
default:
System.out.println("Error: please enter a valid letter");
break;
}
You are missing the arguments in the method call.
case 'a':
case 'A':
System.out.println("your choice A");
add(keyboard); // Add arguments.
break;

Categories

Resources