Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 1: Successor Function [50 points] This is a programming question. The solution to the programming problem should be coded in Java, and you are
Question 1: Successor Function [50 points] This is a programming question. The solution to the programming problem should be coded in Java, and you are required to use only built-in libraries to complete this homework. Please submit a source code file named successor.java with no package statements, and make sure your program is runnable from command line on a department Linux machine. We provide a skeleton successor.java code that you can optionally use, or you can write your own. The goal of this assignment is to become familiar with the state space in a real-world problem. You are given three water jugs with capacity A, B, C liters, respectively. A, B, C are positive integers. At each step, you can perform one of these actions Empty a jug Fill a jug Pour water from one jug to another until either the former is empty or the latter is full. Write a program successor.java to print the successor states of an input state Input: 6 integers A, B, C, a, b, c, where (A, B, C) are the capacity of the jugs, and (a, b, c) are the current amount of water in each jug. You may assume that the input is valid, namely a S A,b B,c C and A, B, C are positive integers, and a, b, c are non-negative integers. Output: Print the list of successor states reachable in one step from (a, b,c), one one each line. The lines do not need to be sorted. The successors should not include (a, b, c) itself Here are some examples of running the program from the command line. The inputs and outputs are space-separated with no comma. Please follow the same input/output format. Example 1 Sjava successor 3 213 20 0 2 0 3 0 0 3 2 1 2 2 1 3 1 1 Example 2 Sjava successor 11 5 263 1 0 3 1 6 0 1 6 3 0 11 3 1 6 5 1 6 3 2 9 01 7 30 4 5 1 6 40 5 3 2 6 2 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started