Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I fix this code so it can work? import javax.swing.JOptionPane; public class Year { public static void main(String[] args) { String str =

How do I fix this code so it can work?

import javax.swing.JOptionPane;

public class Year { public static void main(String[] args) { String str = JOptionPane.showInputDialog("What year were you born?");

int yr = Integer.parseInt(str);

String zodiac = ""; switch (yr%12) { case 0: zodiac = "Monkey"; break; case 1: zodiac = "Rooster"; break; case 2: zodiac = "Dog"; break; case 3: zodiac = "Pig"; break; case 4: zodiac = "Rat"; break; case 5: zodiac = "Ox"; break; case 6: zodiac = "Tiger"; break; case 7: zodiac = "Rabbit"; break; case 8: zodiac = "Dragon"; break; case 9: zodiac = "Snake"; break; case 10: zodiac = "Horse"; break; case 11: zodiac = "Goat"; break; } JOptionPane.showMessageDialog(null, "It is a " + zodiac + " year!", "Chinese Zodiac", JOptionPane.PLAIN_MESSAGE); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

Students also viewed these Databases questions

Question

Describe the job youd like to be doing five years from now.

Answered: 1 week ago

Question

What is topology? Explain with examples

Answered: 1 week ago

Question

What is linear transformation? Define with example

Answered: 1 week ago