1 import java.io.*; 2 import java.util.*; 3 4 // Read only region start 5 class UserMainCode...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 import java.io.*; 2 import java.util.*; 3 4 // Read only region start 5 class UserMainCode 6 { 7 8 9 How to Attempt? Piggy bank Rishe has two piggy banks. In a short period of time, he wants to save money for the trip with his friends. He has decided to save money for N number of days, ie Day-1 to Day- N (inclusive), which is given as input1. He starts on Day-1 by adding the given starting amount input2 to one of the piggy bank, let's say piggy bank-1. On odd days, he will double the money he had saved the previous day in piggy bank-1 and on even days, he will calculate half of what he had saved so far in the piggy bank-1 and save it in piggy bank-2. Calculate the total amount saved on odd days and even days separately. Return the output as "total amount saved on odd days:total amount saved on even days" Function prototype: String piggyBank(int input1, int input2) Note: input1 and input2 is always greater than 0 Example-1 input1: 9 input2: 2 output 62:26 Explanation: 10 11 12 13 public String piggyBank(int input1, int input2){ // Read only region end // Write code here... throw new UnsupportedOperationException("piggyBank(int input1 } } Il tests.mettl.com is sharing your screen. Stop sharing Hide Compile and Test output: 62:26 Explanation: Day 1 Day 2 Day 3 Day4 Day5 Day6 Day7 Day& Day9 Total Piggy bank 1 2 nigh (Odd days) Piggy bank 2 1 3 (Even days) Day-1=2 (input2) Day-2=> (2/2) = 1 Day-3=> 2+2=4 Day-4=> (6/2) = 3 Day-5 => 4+4=8 Day-6=> (14/2) = 7 Day-7=>8+8 = 16 Day-8=> (30/2) = 15 Day-9=> 16 + 16 = 32 Mettl Online Assessment 2021-2031 12 a 2 # Q W S 8 16 32 Z 7 15 29 62 2 import java.util.*; 3 // Read only region start 1456789 class UserMainCode { public String piggyBank(int input1, int input2){ // Read only region end // Write code here... throw new UnsupportedOperationException("piggyBank (int input1 10 11 12 26 } 26 13 } I tests.mettl.com is sharing your screen. Stop sharing Hide Custon Compile and Test Need Help? Contact us: +1 (800) 265-6038 +91 80471-90902 A J $ % 3 4 E R T hp 6 & 7 Y H 8 156325169 insert JK X C B N M Powered By 1 import java.io.*; 2 import java.util.*; 3 4 // Read only region start 5 class UserMainCode 6 { 7 8 9 How to Attempt? Piggy bank Rishe has two piggy banks. In a short period of time, he wants to save money for the trip with his friends. He has decided to save money for N number of days, ie Day-1 to Day- N (inclusive), which is given as input1. He starts on Day-1 by adding the given starting amount input2 to one of the piggy bank, let's say piggy bank-1. On odd days, he will double the money he had saved the previous day in piggy bank-1 and on even days, he will calculate half of what he had saved so far in the piggy bank-1 and save it in piggy bank-2. Calculate the total amount saved on odd days and even days separately. Return the output as "total amount saved on odd days:total amount saved on even days" Function prototype: String piggyBank(int input1, int input2) Note: input1 and input2 is always greater than 0 Example-1 input1: 9 input2: 2 output 62:26 Explanation: 10 11 12 13 public String piggyBank(int input1, int input2){ // Read only region end // Write code here... throw new UnsupportedOperationException("piggyBank(int input1 } } Il tests.mettl.com is sharing your screen. Stop sharing Hide Compile and Test output: 62:26 Explanation: Day 1 Day 2 Day 3 Day4 Day5 Day6 Day7 Day& Day9 Total Piggy bank 1 2 nigh (Odd days) Piggy bank 2 1 3 (Even days) Day-1=2 (input2) Day-2=> (2/2) = 1 Day-3=> 2+2=4 Day-4=> (6/2) = 3 Day-5 => 4+4=8 Day-6=> (14/2) = 7 Day-7=>8+8 = 16 Day-8=> (30/2) = 15 Day-9=> 16 + 16 = 32 Mettl Online Assessment 2021-2031 12 a 2 # Q W S 8 16 32 Z 7 15 29 62 2 import java.util.*; 3 // Read only region start 1456789 class UserMainCode { public String piggyBank(int input1, int input2){ // Read only region end // Write code here... throw new UnsupportedOperationException("piggyBank (int input1 10 11 12 26 } 26 13 } I tests.mettl.com is sharing your screen. Stop sharing Hide Custon Compile and Test Need Help? Contact us: +1 (800) 265-6038 +91 80471-90902 A J $ % 3 4 E R T hp 6 & 7 Y H 8 156325169 insert JK X C B N M Powered By
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Describe how to construct the function cpo ((D E), v) of two cpos (D, vD) and (E, vE). Prove that ((D E), v) is a cpo. (You may use facts about least upper bounds provided you state them clearly.)...
-
Jacomo Companys output for the current period was assigned a $300,000 standard direct materials cost. The direct materials variances included a $44,000 favorable price variance and a $6,000 favorable...
-
The water supply for a midwestern city contains the following impurities: coarse sand, finely divided particulates, nitrate ion, trihalomethanes, dissolved phosphorus in the form of phosphates,...
-
118. The recombination frequency between the genes a &c is 5%, b & c is 15%, b & d is 9%, a & b is 20%, c & d is 24% and a & d is 29%. What will be the sequence of these genes on a linear chromosome?...
-
What are the factors you would have to use in calculating a cost-benefit ratio to support a decision to purchase a new HRIS when the organization already has an HRIS that was acquired 10 years ago?...
-
Humble Company has provided the following budget information for the first quarter of 2016: Total sales ....................$ 208,000 Budgeted purchases of direct materials ....... 40,150 Budgeted...
-
1. 2. The lessee makes a lease payment of $67,200 to the lessor for equipment in an operating lease transaction. Pharoah Company leases equipment from Noble Construction Inc. The present value of the...
-
The pKa of the starting material (Ar-OH) is ~9, which is much more acidic than a normal alkyl alcohol (pKa ~15)? The reason is resonance stabilization of the conjugate base. Please draw the...
-
What does the warranty of habitability require a landlord to do?
-
The business judgment rule makes a director liable for losses to the firm that result from the directors authorized, good faith business decisions. (True/False)
-
The government can take private property for public use without just compensation. (True/False)
-
A corporation is an artificial being. (True/False)
-
In a merger, two or more corporations join to become a completely new corporation. (True/False)
-
Identify and describe the stages of team development.
-
3M Company reports the following financial statement amounts in its 10-K report: a. Compute the receivables, inventory, and PPE turnover ratios for both 2018 and 2017. (Receivables turnover and...
-
If, during a stride, the stretch causes her center of mass to lower by \(10 \mathrm{~mm}\), what is the stored energy? A. \(3.0 \mathrm{~J}\) B. \(6.0 \mathrm{~J}\) C. \(9.0 \mathrm{~J}\) D. \(12...
-
A \(1.00 \mathrm{~kg}\) block is attached to a horizontal spring with spring INT constant \(2500 \mathrm{~N} / \mathrm{m}\). The block is at rest on a frictionless surface. A \(10.0 \mathrm{~g}\)...
-
We can make a static measurement to deduce the spring constant to use in the model. If a \(61 \mathrm{~kg}\) woman stands on a low wall with her full weight on the ball of one foot and the heel free...
Study smarter with the SolutionInn App