Write a Java program that includes in its class the following methods: - ‏- A method named duplicateSentence that takes a String and an integer, and returns a - ‏String that consists of duplicating...


Write a Java program that includes in its class the following methods:


- ‏- A method named duplicateSentence that takes a String and an integer, and returns a


- ‏String that consists of duplicating the passed String number of times that equals the


- ‏passed integer on separate lines.


- ‏For example, if the passed String is Welcome to Java!, and the passed integer is 4, the


- ‏returned String should be:


- ‏Welcome to Java!


- ‏Welcome to Java!


- ‏Welcome to Java!


- ‏Welcome to Java!


- ‏- A method named calculate that takes two double numbers and a character as


- ‏parameters. The character must be one of the four main operations +, -, *, or /. The


- ‏method must return a String that consists of the full equation that includes the two


- ‏numbers, the operation and the result.


- ‏For example, if the passed double numbers are 3.5 and 2.1, and the passed operation is


- ‏+, the returned String must be as follows:


- ‏3.5 + 2.1 = 5.6


- ‏If the passed character does not represent any of the four main operations, the method


- ‏must return the following String: “Wrong operation”.


- ‏- In your main method, test the above two methods:


- ‏o Print the String (Coding is fun!) 10 times by invoking the method


- ‏duplicateSentence.


- ‏o Declare two double variables, and invoke the method calculate and print the result


- ‏of their addition, subtraction, multiplication, and division



Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here