Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Page of 2 0 - ZOOM + lake Problem set 12 Due: Wed. February 5, 1:00 pm. Reading/viewing: Chapter 3 of the lecture notes (Math

image text in transcribed

Page of 2 0 - ZOOM + lake Problem set 12 Due: Wed. February 5, 1:00 pm. Reading/viewing: Chapter 3 of the lecture notes (Math background). Write a Java program called Sums Tojava that determines if +'s can be inserted into a string of digits so that the resulting arithmetic expression sums to a given number. The input is a line containing two strings of digits, each of length at most 18. The output is a single line containing either a 1 if there is such an expression that evaluates to the second number, or -1 if no such expression exists. For example, if the input is 1234 37 then the correct output is Since 1+2+34 - 37 If the input is 1234 500 then the correct output is If the input is 123456789 4248 then the correct output is since 1+2+3156+789 - 4218 (There may be other valid expressions.) If the input is 12345678987654321 9 then the correct output is Your program should terminate in less than a minute for any valid input. Submit your programon Vocareum. Exercises (not to turn in): (1) Suppose that your Sums To program must work for input strings of arbitrary length; denote the length of the first input string by n. How large couki be for your approach to be practical? (2) (Goodrich & Tamaia): An evil king has ne bottles of wine, and a spy has just poisoned one of them. Unfortunately, the king does not know which bottle was poisoned. The poison is very deully but slow-actings a single drop in a bottle of wine will kill anyone tasting it, but only after one month. Page of 2 0 - ZOOM + lake Problem set 12 Due: Wed. February 5, 1:00 pm. Reading/viewing: Chapter 3 of the lecture notes (Math background). Write a Java program called Sums Tojava that determines if +'s can be inserted into a string of digits so that the resulting arithmetic expression sums to a given number. The input is a line containing two strings of digits, each of length at most 18. The output is a single line containing either a 1 if there is such an expression that evaluates to the second number, or -1 if no such expression exists. For example, if the input is 1234 37 then the correct output is Since 1+2+34 - 37 If the input is 1234 500 then the correct output is If the input is 123456789 4248 then the correct output is since 1+2+3156+789 - 4218 (There may be other valid expressions.) If the input is 12345678987654321 9 then the correct output is Your program should terminate in less than a minute for any valid input. Submit your programon Vocareum. Exercises (not to turn in): (1) Suppose that your Sums To program must work for input strings of arbitrary length; denote the length of the first input string by n. How large couki be for your approach to be practical? (2) (Goodrich & Tamaia): An evil king has ne bottles of wine, and a spy has just poisoned one of them. Unfortunately, the king does not know which bottle was poisoned. The poison is very deully but slow-actings a single drop in a bottle of wine will kill anyone tasting it, but only after one month

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Database Technology Edbt 88 International Conference On Extending Database Technology Venice Italy March 14 18 1988 Proceedings Lncs 303

Authors: Joachim W. Schmidt ,Stefano Ceri ,Michele Missikoff

1988th Edition

3540190740, 978-3540190745

More Books

Students also viewed these Databases questions