Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8539965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:29:29+00:00 2026-06-11T11:29:29+00:00

How to correcting error in line char oper = entrada.next(); //ERROR HERE in code:

  • 0

How to correcting error in line

char oper = entrada.next(); //ERROR HERE

in code:

/*
 * Calculator
 */
package list01;

import java.util.Scanner;

public class ex04 {

    public void metodoEx04() {
        Scanner entrada = new Scanner(System.in);
        System.out.print("First number: ");
        int A = entrada.nextInt();
        System.out.print("Second number: ");
        int B = entrada.nextInt();
        System.out.print("Operator +, -, *, ou /: ");
        char oper = entrada.next(); //ERROR HERE
        double res = calculadora(A, B, oper);
        System.out.println(res);
    }

    static double calculadora(int n1, int n2, char operador) {
        double res;
        switch (operador) {
            case '+':
                res = soma(n1, n2);
                return res;
            case '-':
                res = subtracao(n1, n2);
                return res;
            case '*':
                res = multiplicacao(n1, n2);
                return res;
            default:
                res = divisao(n1, n2);
                return res;
        }
    }

    static double soma(int num1, int num2) {
        double res;
        res = num1 + num2;
        return res;
    }

    static double subtracao(int num1, int num2) {
        double res;
        res = num1 - num2;
        return res;
    }

    static double multiplicacao(int num1, int num2) {
        double res;
        res = num1 * num2;
        return res;
    }

    static double divisao(int num1, int num2) {
        double res;
        if (num2 != 0) {
            res = num1 / num2;
            return res;
        } else {
            System.out.println("Impossible.");
            return 0.0;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:29:31+00:00Added an answer on June 11, 2026 at 11:29 am

    next gives a string, you want a char. You could try

    char oper = entrada.next().charAt(0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use an error correcting technique on short messages (between 100 and
ms-access is connecting to a local mysql database the following code returns an error:
I have problem running and debugging this piece of code: bool readSectionHeaders(char* path, int
I'm currently writing program to encode and decode messages via error-correcting cyclic codes. My
I'm learning WPF and XAML. Here is my Form XAML code and the code
Here is my Form XAML code. <Window x:Class=Bail.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns=clr-namespace:Bail Title=MainWindow Height=768 Width=1024
There is a mysterious error at the line ee.add(new BasicNameValuePair(uid,demo)); Eclipse says: Multiple markers
all I have an error begin thrown up when I am running my code.
I hope someone here can help me see where this error is coming from.
I'm trying to do some Socket programming in Java, and I'm using the BufferedStreamReader.read(char[])

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.