EssayGhost Assignment代写,Essay代写,网课代修,Quiz代考

EssayGhost-Essay代写,作业代写,网课代修代上,cs代写代考

一站式网课代修,论文代写

高质量的Assignment代写、Paper代写、Report代写服务

EG1hao
网课代修代上,cs代写代考
Java代做
您的位置: 主页 > 编程案例 > Java代做 >
代做Java:JAVA Assignment 基础本科留学生CS作业加急代写 - Java代做
发布时间:2021-07-25 10:25:23浏览次数:
Can be solved individually or in groups of 2 studentsCreate a zip file containing the required deliverables with all files containing the studentsnames and numbers ( one submission per team)Q1) Creating the stack classesYouarerequiredtowriteyourowngenericstackimplementationinJavathatyouwilluseinquestions 2 and 3. (30marks)a.Create a stack interface Stack T that uses a generic type T and has the following abstractmethods: isEmpty, isFull, peek (returns T), pop(returns T), void push(T), void clear() to clear the contents of the stack0, and int size (returns the number of elements in thestack). void reverse() reverses the contents of the stack ( in your implementation you can use an additional local stack in your method to help you with the reverseoperation.) void display() prints out the contents of the stack (Hint: you can obtain the contents of your stack elements usingtoString())b.Write your two stack implementations (ArrayStack T and ListStack T ) using the stackinterface.c.Your stack implementations must have all instance variables asprivate.d.Both implementations must a constructor that initializes the capacity of the stack. For the ListStack, the stack is full when the size reaches the initialcapacity.e.YoumustalsoimplementpublicStringtoString()inbothclasses.ItreturnsaStringrepresentationof the stackcontents.c. Create a simple main class QuestionOne that creates two stacks of Integers of capacity=20 one that uses the ArrayStack Integer and the other uses the ListStack Integer implementations. Push 20 values in each: in the first (1,2,3,…,20) and in the second (20, 19,..,13,.., 1). Call the following methods for both stacks in the given order: display, reverse, display, peek, pop, pop, reverse, size, isFull, isEmpty, display, clear, display, isEmpty.Deliverable: folder Q1Stack.javaArrayStack.javaListStack.javaQuestionOne.javaQ2) Simple calculator (35 marks):YouaretodesignasimplecalculatorusingtheArrayStackimplementationinQ1toperformadditions, subtractions, multiplications and divisions. The user may enter an arithmetic expression in infixusing numbers (0 to 9), parentheses((,),{,},[,], , ) and the four arithmetic operations (+, -, *, /)only.The first step to do so is to create a utility class MyCalculator that will have the following methods: a) Input of an expression and checking Balanced Parenthesis:public static Boolean isBalanced(String expression)This is a static method that will read a string representing an infix ((operand operation operand)) mathematical expression with parentheses from left to right and decide whether the brackets are balanced or not. For example, (5*{7+22} is not valid, but (5*{7+22}) is valid.Todiscoverwhetherastringisbalancedeachcharacterisreadinturn.Thecharacteriscategorized as anopeningparenthesis,aclosingparenthesis,oranothertypeofcharacter.Valuesofthethirdcategory are ignored for now. When a value of the first category is encountered, the corresponding close parenthesis is stored in the stack. For example, when a “(“ is read, the character “)” is pushed on the stack. When a “{“ is encountered, the character pushed is “}”. The topmost element of the stack is therefore the closing value we expect to see in a well balancedexpression.Whenaclosingcharacterisencountered,itiscomparedtothetopmostiteminthestack.Ifthey match, the top of the stack is popped and execution continues with the next character. If they do not matchanerrorisreported(displayamessageabouttheerrorandreturnfalse).Anerrorisalsoreported ifaclosingcharacterisreadandthestackisempty.Ifthestackisemptywhentheendoftheexpression is reached then the expression is wellbalanced.For this application a parenthesis can be one of the following:-parantheses:() angle brackets: -curly braces:{ } -square brackets: [ ] These must be defined as constants in theclass.b)Infix to PostfixconversionWrite a method that converts Infix expressions to postfix expressions using your stack implementation:public static String infixToPostfix(String infix)The method only takes balanced expressions with balanced parenthesis. The return is a string that has the Postfix expression of the input string.c)Evaluating a PostfixexpressionWrite a method that evaluates a postfix expression: public static double evaluate(string postfix);d)Your main classQuestionTwoTo evaluate your methods create theclassQuestionTwo It must contain a public static void main(String[]args)methodtorunyourcode.Thismainmethodshouldasktheusertoinputoneinfixexpressionperlineuntiltheusertypes“q”or“Q”.Aftereveryinput,itshouldfirsttestiftheexpression has balanced paranthesis and tells the user if the expression is balanced or not.If the expression is balanced it will convert it into a postfix expression, displays the expression and then evaluates it and outputs the results and then ask for the next input.If the expression is not balanced it tells the user that and asks for a new input.Some rules:-You should assume no whitespace in the infix expression provided by the user. For example, your code should work for inputs like “2+(3×2)”. The postfix that you will print, however, should have tokens separated by whitespace. For example, “3×21” should have the postfix“3 21 ×”, and not “321×”. Here is a suggested part of your main that you can useimport java.util.Scanner; public class QuestionTwo{public static void main(String[] args){Scanner calcScan = new Scanner(System.in); Boolean finished=false;while (!finished){System.out.println( Enter a postfix expression or q to quit: String expression = calcScan.nextLine(); System.out.println(expression);expression.trim();//omits leading and trailing whitepsaces System.out.println(expression);if (expression.equalsIgnoreCase( q )){finished=true;} else{//use your MyCalculator methods here}}}}Deliverables: MyCalculator.java-QuestionTwo.javaQ3) Towers of Hanoi (35 marks):You are required to design an algorithm which solves the Tower of Hanoi puzzle (see the figure below). The objective of the puzzle is to move n discs from one tower to another, but with somerules in place as describedbelow.In your algorithm, the towers will be represented with an array of stacks called rods with size3 (three towers). All three of the stacks have the same capacity which isn.At the beginning:rods[0] (first stack representing the first tower in the picture) is full of discs marked with positive integers from 1 to n where 1 is at the top smallest disc and n is at the bottom ( i.e., you need and array ofthreestacksofIntegerswiththefirstinitializedtostorethenIntegersandtheothertworodsareempty).The other two stacks areempty.The goal of the puzzle:is to move all these discs from rods[0] to the third rod, rods[2], with the help of rods[1], without breaking any rules of the Tower of Hanoi puzzle.The rules of the game are:·Only one disc may be moved at atime.·Each move consists of taking the top (smallest) disc from one of the rods and sliding it onto another rod, on top of the other discs that may already be present on thatrod.·No disk may be placed on top of a smallerdisk.Hints:TomoveastackofkdiscsfromrodAto rodB,wefirst movek-1 discsfromAtoC,then movethe remaining (kth) disc from rod A to B, and then finally move all k-1 discs on C to B. Also, if you closely examine the puzzle you will see that there is at most one legal move between any tworods.Deliverables:TowersofHanoi.java

所有的编程代写范围:essayghost为美国、加拿大、英国、澳洲的留学生提供C语言代写、代写C语言、C语言代做、代做C语言、数据库代写、代写数据库、数据库代做、代做数据库、Web作业代写、代写Web作业、Web作业代做、代做Web作业、Java代写、代写Java、Java代做、代做Java、Python代写、代写Python、Python代做、代做Python、C/C++代写、代写C/C++、C/C++代做、代做C/C++、数据结构代写、代写数据结构、数据结构代做、代做数据结构等留学生编程作业代写服务。