1. Which variable names are legal, which are not? (5 pts) 1.1) 3abc 1.2) _myABC 1.3)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Which variable names are legal, which are not? (5 pts) 1.1) 3abc 1.2) _myABC 1.3) _1_2_3_a_b_c 1.4) ABC 1.5) x@y 2. Calculations (5 pts): 2.1) 100 % 30 * 2 2.2) 25-8/10 2.3) 8*2%3 2.4) 13 % 15 2.5) 22% 11 3. Which Java code is correct? Which is not? Explain the reason if it is not correct. (6 pts) 3.1) int 3.2) 3.3) double char int 3 W = 1; double pi= pi * 2; X; Y; X; W; pi; 4. How do I check an integer variable, x, is greater than 5 but less than 20? Please write down your Java expression (2 pts). 5. Please fill out the table (result should be either true or false) (5 pts) Result 6.2) 6. What will be the output of each code part below? (each code part is independent) (4 pts) 6.1) ! (99 > 100) (1> 0) && (2> 3) && (102<100) (0 == 1) // (12+ 3 > 20) // (6 != 2) int if (A % 2 == 0) { A = A/2; } else { } Expression (20<40) && (1 != 0) (1 == 0) // (2 == 3) A = 2022; } else { System.out.println (A); } A=A-1; int if (x != 2020) { x = 2022; X = X-1; x= x + 1; System.out.println("x is " + x); 7. (2 pts) What will be output if the initial value of magicNum is 22 ? switch (magicNum % 7) { case 1: } case 3: case 5: magicNum *= 3; break; magicNum += 5; break; magicNum - -= 2; break; magicNum = 7; default: 17 System.out.println ("magicNum is + magicNum); 8. Read the code and answer the questions below. (4 pts) year = input.nextint(); if (year >= 1776) { System.out.println ("The New Nation"); } else if (year >= 1861) { System.out.println ("Civil War"); } else if (year >= 1877) { System.out.println ("Rise of Industrial"); } else if (year >= 1900) { } System.out.println ("New Era") 8.1 What will be the output if the input year is 1899 ? 8.2 What will be the output if the input year is 1690? 9. Below is an incomplete code part that is going to read TWO integers from user input. The code is supposed to print the larger value of them. Please finish the code (4 pts). int number1, number2; Scanner input = new Scanner(System.in); number1= input.nextlnt(); number2 = input.nextint(); 1. Which variable names are legal, which are not? (5 pts) 1.1) 3abc 1.2) _myABC 1.3) _1_2_3_a_b_c 1.4) ABC 1.5) x@y 2. Calculations (5 pts): 2.1) 100 % 30 * 2 2.2) 25-8/10 2.3) 8*2%3 2.4) 13 % 15 2.5) 22% 11 3. Which Java code is correct? Which is not? Explain the reason if it is not correct. (6 pts) 3.1) int 3.2) 3.3) double char int 3 W = 1; double pi= pi * 2; X; Y; X; W; pi; 4. How do I check an integer variable, x, is greater than 5 but less than 20? Please write down your Java expression (2 pts). 5. Please fill out the table (result should be either true or false) (5 pts) Result 6.2) 6. What will be the output of each code part below? (each code part is independent) (4 pts) 6.1) ! (99 > 100) (1> 0) && (2> 3) && (102<100) (0 == 1) // (12+ 3 > 20) // (6 != 2) int if (A % 2 == 0) { A = A/2; } else { } Expression (20<40) && (1 != 0) (1 == 0) // (2 == 3) A = 2022; } else { System.out.println (A); } A=A-1; int if (x != 2020) { x = 2022; X = X-1; x= x + 1; System.out.println("x is " + x); 7. (2 pts) What will be output if the initial value of magicNum is 22 ? switch (magicNum % 7) { case 1: } case 3: case 5: magicNum *= 3; break; magicNum += 5; break; magicNum - -= 2; break; magicNum = 7; default: 17 System.out.println ("magicNum is + magicNum); 8. Read the code and answer the questions below. (4 pts) year = input.nextint(); if (year >= 1776) { System.out.println ("The New Nation"); } else if (year >= 1861) { System.out.println ("Civil War"); } else if (year >= 1877) { System.out.println ("Rise of Industrial"); } else if (year >= 1900) { } System.out.println ("New Era") 8.1 What will be the output if the input year is 1899 ? 8.2 What will be the output if the input year is 1690? 9. Below is an incomplete code part that is going to read TWO integers from user input. The code is supposed to print the larger value of them. Please finish the code (4 pts). int number1, number2; Scanner input = new Scanner(System.in); number1= input.nextlnt(); number2 = input.nextint();
Expert Answer:
Answer rating: 100% (QA)
The detailed answer for the above question is provided below 1 Variable Names 11 Illegal Variable na... View the full answer
Related Book For
Understanding Financial Accounting
ISBN: 978-1118849385
1st Canadian Edition
Authors: Christopher Burnley, Robert Hoskin, Maureen Fizzell, Donald
Posted Date:
Students also viewed these programming questions
-
Please return the code as an answer not instructions.Please write the code in Java and it should be working /* Problem 7: **** 1* Write a loop that visits every ******************* tile on a grid...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
There are two major producers of corncob pipes in the world. Suppose that the inverse demand function for corncob pipes is described by p = 120 - 4g where g is total industry output and suppose that...
-
24. Find the minimum distance between the point (1, 2, 0) and the quadric cone z2 = x2 + y2.
-
A 1400 kg car driving at 25 m/s slams on its brakes. The coefficient of kinetic friction between the tires and the road 0.7. What is the magnitude and direction of the acceleration of the car? Bonus:...
-
Use the working papers from Application Problem 20-2 to complete this problem. Instructions: Prepare a statement of cost of goods manufactured for Cramer Corporation. The statement is for the month...
-
Aurora Company is considering the purchase of a new machine. The invoice price of the machine is $140,000, freight charges are estimated to be $4,000, and installation costs are expected to be...
-
> > $ JB 50 ORIOLE INC. Sales Budget $ $ $ JB 60 Total
-
What are the triads using roman numerals and figured bass numbers for this excerpt? 30-3. Use Roman numerals and figured bass numbers to identify triads in these works. a. Schubert, "Death and the...
-
while conducting your analysis you may want to consider and identify the various design elements that are present in the excerpt (ie, use of alignment, chunking, use of color, etc) how effective are...
-
Why are there no laws of psychology?
-
Please summarize the changing use of positive psychology over time, including how it compares with other theories in personality psychology. Consider the future relevance of positive psychology...
-
Psychology is an objective and systematic study of how people behave and think.Based on your understanding, why do you thing Psychology is a part of Science Field. sample text sample text x C E=mc...
-
Firms often seek to improve their profit margins by acquiring a supplier - the motive being to capture the supplier's profit (net income) as well as their own. Some financial data is provided in the...
-
2. (5 possible points) Below is an incomplete graph of foramen magnum index (FMI) and average cranial capacity (ACC) (ccm). The graph has been pre-populated with one data point, M, which represents...
-
Negligence in Healthcare Choose a contemporary example of medical negligence in healthcare. You can begin by visiting the Internet Resources provided by your textbook , journals, case studies, as...
-
Frontland Advertising creates, plans, and handles advertising campaigns in a three-state area. Recently, Frontland had to replace an inexperienced office worker in charge of bookkeeping because of...
-
List and briefly describe the three rights that common shareholders typically have in a corporation.
-
Crafty Resources Ltd. is a new creator and publisher of childrens craft kit books. It has created kits for dolls, twirled paper crafts, paper doll clothes, and so on. The publishing industry is...
-
Use the same abbreviations as in AP1-8 to answer the following question. In AP Required: Classify the following items according to where they would appear in the financial statements: a. Intangible...
-
Ortega Industries has a fully funded pension plan. Each year, pension expense runs in excess of \(\$ 10\) million. At the present time, employees are entitled to receive pension benefits with a...
-
What are the basic rights of the owner of a share of corporate stock? In what way are these basic rights commonly modified with respect to the owner of a share of preferred stock?
-
Explain the following terms: a. Stock transfer agent. b. Stockholders subsidiary ledger. c. Underwriter. d. Stock registrar.
Study smarter with the SolutionInn App