1. Use while loop or do while loop to rewrite the following code segment. for(int i=1,j=10;i...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Use while loop or do while loop to rewrite the following code segment. for(int i=1,j=10;i<=10; i++,j--) { System.out.println(i++); } if(i==j) break; Sysmtem.out.println(j); 2. Rewrite the following code segment using a multiple-selection statement (switch) in Java language. if ((k==1)||(k==2)) if ((k==3)||(k==5)) if (k==4) if ((k==6)|| (k==7)|| (k==8)) j=2*k-1; j=3*k+1; j=4*k-1; j=k-2; 1. Use while loop or do while loop to rewrite the following code segment. for(int i=1,j=10;i<=10; i++,j--) { System.out.println(i++); } if(i==j) break; Sysmtem.out.println(j); 2. Rewrite the following code segment using a multiple-selection statement (switch) in Java language. if ((k==1)||(k==2)) if ((k==3)||(k==5)) if (k==4) if ((k==6)|| (k==7)|| (k==8)) j=2*k-1; j=3*k+1; j=4*k-1; j=k-2;
Expert Answer:
Related Book For
Essentials Of Computer Organization And Architecture
ISBN: 9781284259438
6th Edition
Authors: Linda Null, Julia Labur
Posted Date:
Students also viewed these programming questions
-
For the following code segment 1 int sum = 0; 2 3 for (int i 0; i < 5;) { %3D 4 sum = sum + i; 5 } 6. 7 System.out.println(sum); 8 The program will end in an infinite loop. The program has a compile...
-
Using C++, write a program to answer the following. Write code that lets the user enter a number. The number should be multiplied by 4 and printed until the number exceeds 60. Use a while loop. 2....
-
The retail inventory method is used by The Bronx Company. Inventory, purchases, and sales data for 2016 are as follows: Using the retail method, calculate the Lower-of-Average-Cost or Market of the...
-
Gordon Grimes, a self-employed consultant near Atlanta, received an invitation to visit a prospective client in Seattle. A few days later, he received an invitation to make a presentation to a...
-
Tesco PLC is the United Kingdoms biggest grocery retailer and the worlds fifth largest, with nearly half a million employees, pre- tax revenues exceeding 63 billion, and over 7,000 stores globally,...
-
A gasoline engine consumes 8 litres of fuel per hr. having specific gravity of 0.75 while it develops \(25 \mathrm{~kW}\) power. If the C.V. of fuel used is \(44200 \mathrm{~kJ} / \mathrm{kg}\),...
-
As a financial consultant at Alexandra Anderson & Co., you and your team have been assigned to work on the WalterCola account, a fortune 500 soft drink beverage producer. Max Prophet, CEO of WC, has...
-
Everyone knows that Serial Killer Sam is guilty of a lot of stuff. If Bruce Banner goes home for the holidays and finds Serial Killer Sam camping out in his backyard in Illinois, how come he has to...
-
1. Figure 1 reproduces John's notes on Pioneer Gypsum and Global Mining. Calculate the expected return, risk premium, and standard deviation of a portfolio invested partly in the market and partly in...
-
Excel Homework #1 1. Create any logical function by using one of the following logical operators: AND, OR, NOT. 2. Create any "IF" function that uses a simple "named range" in calculation based on...
-
A bond is available for purchase in the financial markets. The bond is a 3-year, $1,000 bond that pays an annual coupon of 10 percent. What is the duration of the bond if the current...
-
A firm can issue $1,000 par value bond that pays $100 per year in interest at a price of $980. The bond will have a 5-year life. The firm is in a 35% tax bracket. What is the after tax cost of debt?
-
The standard deviation of market returns is 20%. Stock ZZZ has a market beta of 1.9 and a residual standard deviation of 30%. The CAPM holds. What is the correlation between the market returns and...
-
Assume an organization encourages casual dress and has a long tradition of having "beer Fridays," where they provide snacks to allow teams to get together in a casual environment. What concept does...
-
1. Calculate the weight (in newtons) of an astronaut (mass of 100 kg) on a planet where the acceleration due to gravity is 6.63 meters per second squared. Round your answer to two decimal places. 2....
-
2. Two sets of parents who have children with Down syndrome meet at a clinic. The Phelps know that their son has trisomy 21. The Watkins have two affected children, and Mrs. Watkins has had two...
-
You are maintaining a subsidiary ledger account for Police-Training Expenditures for 2013. The following columns are used: Inventory purchases are initially recorded as expenditures. Record the...
-
How does a maskable interrupt differ from a nonmaskable interrupt?
-
What is meant by preemptive scheduling?
-
What does an algorithmic state machine offer that is not provided by either a Moore or a Mealy machine?
-
Find the most economical diameter of Sch. 40 commercial steel pipe that would be needed to transport a petroleum fraction with a viscosity of $60 \mathrm{cP}$ and $\mathrm{SG}$ of 1.3 at a rate of...
-
A roof drains into a gutter, which feeds into a downspout with a square cross section (4 in. $x$ 4 in.). The discharge end of the downspout is $12 \mathrm{ft}$ below the entrance and terminates in a...
-
A concrete-lined drainage ditch has a triangular cross section that is an equilateral triangle, $8 \mathrm{ft}$ on each side. The ditch has a slope of $3 \mathrm{ft} / \mathrm{mile}$. What is the...
Study smarter with the SolutionInn App