Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

227
Views
Uso del interruptor para separar salidas de diferentes letras

¿Hay alguna forma de que si un usuario ingresa cualquier letra excepto T, M o S, se generará otra? O tengo que hacer un caso para cada letra y poner otro? ¿Hay alguna forma de agruparlos para el 'caso'? Como por ejemplo,

 case "A - Q": System.out.print("Other"); break;

Obviamente no puedes hacer eso, pero ¿algo así?

 import java.util.Scanner; public class SwitchPractice { public static void main(String args[]) { Scanner input = new Scanner(System.in); String employeeCode; System.out.print("Enter employees code: "); employeeCode = input.next(); switch (employeeCode) { case "T": System.out.print("Technician"); break; case "S": System.out.print("Sales"); break; case "M": System.out.print("Marketing"); break; case "?": System.out.print("OTHER!"); } } }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Utilice un caso predeterminado. Por ejemplo:

 import java.util.Scanner; public class SwitchPractice { public static void main(String args[]) { Scanner input = new Scanner(System.in); String employeeCode; System.out.print("Enter employees code: "); employeeCode = input.next(); switch (employeeCode) { case "T": System.out.print("Technician"); break; case "S": System.out.print("Sales"); break; case "M": System.out.print("Marketing"); break; default: System.out.print("OTHER!"); break; } } }

Este caso predeterminado se ejecutará siempre que la letra no sea "T", "M" o "S".

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!