Listing 3.9 using an array of strings to store the animal names. Listing 1 import java.util.Scanner; 2
Question:
Listing 3.9 using an array of strings to store the animal names.
Listing
Transcribed Image Text:
1 import java.util.Scanner; 2 3 public class ChineseZodiac { public static void main(String[] args) { Scanner input = new Scanner(System.in); 4 5 System.out.print("Enter a year: "); int year = input.nextInt(); 8 switch (year % 12) { case 0: System.out.println ("monkey"); break; case 1: System.out.println("rooster"); break; case 2: System.out.println("dog"); break; case 3: System.out.println("pig"); break; case 4: System.out.println("rat"); break; case 5: System.out.println("ox"); break; case 6: System.out.println("tiger"); break; case 7: System.out.println("rabbit"); break; case 8: System.out.println("dragon"); break; case 9: System.out.println("snake"); break; case 10: System.out.println("horse"); break; case 11: System.out.println("sheep"); 10 11 12 13 14 15 16 17 18 19 20 22 23 24 25 } Enter a year: 1963 -Enter rabbit Enter a year: 1877 -Enter oX 222N 22
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 55% (9 reviews)
Program plan o Read the year form user o Display the Chinese zodiac sign for en...View the full answer
Answered By
Muhammad Umair
I have done job as Embedded System Engineer for just four months but after it i have decided to open my own lab and to work on projects that i can launch my own product in market. I work on different softwares like Proteus, Mikroc to program Embedded Systems. My basic work is on Embedded Systems. I have skills in Autocad, Proteus, C++, C programming and i love to share these skills to other to enhance my knowledge too.
3.50+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
a. You are given an array of integers, where different integers may have different numbers of digits, but the total number of digits over all the integers in the array is n. Show how to sort the...
-
The sort method, when applied to an array of strings, returns a copy of that array in which the strings appear in alphabetical order. For example, if the variable words stored the array ['foo',...
-
Parameter: An array of strings. Return value: A list of the unique strings in the parameter array. Write, test, and debug (if necessary) PHP scripts for the specifications that above. For Exercise,...
-
For the increasing marginal-extraction-cost model of the allocation of a depletable resource, how would the ultimate cumulative amount taken out of the ground be affected by (a) An increase in the...
-
Use a Venn diagram to illustrate the relationships A B and B C.
-
identifying the functions and roles of the broadcast station general manager and the skills necessary to carry them out
-
Distinguish between physical asset markets and financial asset markets. AppendixLO1
-
At the end of May, the first month of operations, the following selected data were taken from the financial statements of Julie Mortenson, Attorney at Law, P.C.: Net income for May ....... $127,500...
-
Mama Berhad ("Mama") has annual sales of RM4 million and a gross profit margin of 40%. Its end-of- quarter inventories are as follows: Quarter 1 2 3 4 Inventory (RM) 400,000 800,000 1,200,000 200,000...
-
Assume that the actual expectation of the measurement is equal to 2.3 (=2.3). Then the expectation of the statistic that was proposed by Statistician A is equal to:____________________.
-
Write the following method that partitions the list using the first element, called a pivot.public static int?partition(int[] list)After the partition, the elements in the list are rearranged so that...
-
Write a method that returns a sorted string using the following header: public static String sort(String s) For example, sort("acb") returns abc. Write a test program that prompts the user to enter a...
-
In the United States, steel production has remained constant since the 1970s at about 100 million tons per year. Large integrated companies, like U.S. Steel remain important in the industry, but...
-
Beswick Limited manufactures mountain and road bikes. The trial balance at 3 1 December 2 0 2 0 was as follows: Dr Cr Revenue 3 , 5 6 4 , 3 0 0 Purchases 1 , 5 7 8 , 2 5 0 Inventory on 3 1 / 1 2 / 1...
-
Kubin Company's relevant range of production is 10,000 to 12,000 units. When it produces and sells 11,000 units, its average costs per unit are as follows: Average Cost per Unit $ 7.10 Direct...
-
Smithen Company, a wholesale distributor, has been operating for only a few months. The company sells three products-sinks, mirrors, and vanities. Budgeted sales by product and in total for the...
-
For the demand equation, express the total revenue R as a function of the price p per item. R(p) q=-6p+ 600 Sketch the graph of the resulting function. 20000 19000 18000 17000 16000 O 15000 14000...
-
Kosovski Company is considering Projects S and L, whose cash flows are shown below. These projects are mutually exclusive, equally risky, and repeatable. The WACC is 11.50%. Year: 0 1 2 3 4 CF for S:...
-
While the system of checks and balances works to prevent the accumulation of too much power by any one branch of the government, it also causes problems in the functioning of government. What do you...
-
If the annual fixed costs are 54,000 dinars, the occupation expense represents 20%, the contribution margin is 25%, and the unit selling price is 40 dinars. Required: Calculate the closing point of...
-
Magic 8 Ball is a toy developed in the 1950s and used for fortune-telling or advice-seeking. A player asks or thinks of a yes-or-no question such as, Will I be rich someday? The player then turns the...
-
a. Write an application that accepts up to 20 Strings, or fewer if the user enters a terminating value. Store each String in one of two listsone list for short Strings that are 10 characters or fewer...
-
a. Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data...
-
(Present-value comparison)You are offered $100,000 today or $360,000 in 13 years. Assuming that you can earn 12 percent on your money, which should you choose? If you are offered $360,000 in 13 years...
-
Specify why is S15-2 still prevalent if Fringe Benefit Tax Assessment Act is active?
-
You have just sold a cemetery plot. As part of the sale, you have agreed to maintain the grass and flowers in perpetuity. You expect maintenance costs to be $62 due at the end of each year, forever....
Study smarter with the SolutionInn App