Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise we'll be using a combination of things we've worked on before, but now starting almost from scratch. No individual element here is

In this exercise we'll be using a combination of things we've worked on before, but now starting almost from scratch. No individual element here is new, so read the instructions carefully and break the task down into steps.

In the skeleton you are given a class Sequence with very little code in it. It starts with an array called sequence, and that's about it.

Below the indicated comment you need to do the following (you may want to think about the order):

  • Create a standard main method. In the main method you need to:

    • Create a Scanner object to be used to read things in

    • Print a prompt to "Enter the first double: ", without a new line after it.

    • Read a double in from the user and store it as the first element of sequence.

    • Print a prompt to "Enter the second double: ", without a new line after it.

    • Read a double in from the user and store it as the second element of sequence.

    • Calculate a third double which is the seconddouble divided by the first double, all multiplied by the second double.

    • Store this third double as the third element of sequence.

    • Print "The first element was , the second element was , so the third element is ." where , and are replaced by the values of the first, second and third doubles respectively.

Remember that computers aren't clever, so note the formatting and punctuation, especially in the feedback of the tests.

Note also that part of the task is to use the array sequence. Although you can print out the correct things without it, you cannot pass the task.

As an example, you have also been given the class AreaOfRectangle, you do not need to change anything, it is just to help you.

import java.util.Scanner;

public class Sequence {

static double [] sequence = {0, 0, 0};

// DO NOT CHANGE ANYTHING ABOVE THIS COMMENT LINE //Create a main method //Create a Scanner //Prompt the user as per the description and read in a double. //Prompt the user as per the description and read in another double.

//Calculate the third double.

//Print out the message about the sequence values.

//Don't forget to put a closing brace at the end of the main method. }

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

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago