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
-
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...
-
Jed, age 55, is married with no children. During 2016, Jed had the following income and expense items: a. Three years ago, Jed loaned a friend $10,000 to help him purchase a new car. In June of the...
-
Presented below is a schedule of property dispositions for Hollerith Co. The following additional information is available. Land: On February 15, a condemnation award was received as consideration...
-
Consider the calculation of an external rate of return (ERR). The positive cash flows in the cash flow profile are moved forward to \(t=n\) using what value of \(i\) in the \((F \mid P i, n-t)\)...
-
A gas containing water vapor has a dry-basis composition of 8.5 mole% CO. 10.5% CO2, 0.5% O2, and 80.5% N2. The gas leaves a catalyst regeneration unit at 620C and 1 atm with a dew point of 57C at a...
-
Date Account Title Debit Credit Sept 1 Cash 10,000 Common Stock 10,000 Sept 2 Equipment 5,000 Cash 5,000 Sept 3 Rent Expense 400 Cash 400 Sept 4 Supplies 500 Cash 500 Sept 5 Advertising Expense 250...
-
George S. Avery signed a letter regarding the unpaid balance on a $20,000 promissory note owed to Jim Whitworth in the form of a letter addressed to Whitworth stating: This is your note for...
-
Let PrefRep be the set of all languages AE that are prefix-repetitive, by which we mean that there are infinitely many strings we * such that ww XA. (a) Prove that (Pref Rep|DEC) = 0. (b) Prove that...
-
Falling in line with their credit score, the estimated salary is provided whenever acustomer requests a new product. The number of products indicates the number of products eachcustomer uses, such as...
-
Deckko Co owns two firms: a dairy company and a snack company. The dairy company has stable, predictable sales. The snack company is constantly innovating to try and discover a high-value product,...
-
Sometimes a construction has a long-term project like building a skyscraper in Chicago for another company for which it is paid quarterly for the work it has done each quarter over a five-year...
-
Are we unconsciously or consciously calculating costs and rewards in our relationships? Asking ourselves if we get less out of a relationship than we put in? And are we always clear about what our...
-
Smith & Jones Inc.'s stockholders are mostly individual investors, and there is relatively little institutional ownership. If several pension and mutual funds were to take large positions in Smith &...
-
Determine the diameter d of a circular pipe to discharge Q 1 1/s for a given loss of pressure head in the system. Given: 1 = 111 m k = 5 mm, hLoss, continuous/=0.02 Q = 1 1/s T = 10 C
-
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...
-
Renaldo borrows $8,000 from his aunt today to help pay for college expenses. He agrees to repay the loan according to the following schedule, at a rate of 6 percent/year compounded annually. a. Draw...
-
Ken loans his grandson Rex $20,000 at 5.5 percent per year to help pay for executive chef schooling in Florida. Rex requires 3 years of schooling before beginning to earn a salary. He agrees to pay...
-
An investment has the following cash flow series where interest is 8 percent a. Determine the present worth of the series. b. Determine the future worth of the series at the end of year 8. c. Find...
Study smarter with the SolutionInn App