How do you get a method from recursing infinitely

Assignment Help Basic Computer Science
Reference no: EM131032465

How do you get a method from recursing infinitely?  In the example below, It asks for a double value, then another.  The first value must be less than the second value.  If not, it will ask you to enter a double that is less than the second one.  After that, it will allow you to enter 2 more doubles but the problem is it keeps going and won't stop.  So what do I need to put in there to make it stop afterwards?

Example:

public static void getOperands() {

Scanner scnr = new Scanner(System.in);
    System.out.println("Enter a double value");
    double operand1 = scnr.nextDouble();

    System.out.println("Enter another double value");
    double operand2 = scnr.nextDouble();

if(operand1 < operand2) {

calcPercentage(operand1, operand2);

}
else
    System.out.println("Enter a double that is less than the second double");
    getOperands();
}

Reference no: EM131032465

Questions Cloud

Age of the mother-marital status of mother : Problem: As part of a data base on new births at a hospital some variables recorded are the age of the mother, marital status of the mother (single, married, divorced, other), weight of the baby, and sex of the baby. Of these variables
What are busses and ports plx : What are busses and ports plx give me some to the point answer for this sir plx
Quantitative analysis for the two companies on profitability : A highlighting of the most important changes within these ratios and an identification of the reasons for these changes. A comparison of the quantitative analysis for the two companies on Profitability, Asset efficiency, Liquidity, Capital structu..
Compare the tax advantages of debt versus equity capital : Imagine that you are a Certified Public Accountant (CPA) with a new client who needs an opinion on the most advantageous capital structure of a new corporation.
How do you get a method from recursing infinitely : How do you get a method from recursing infinitely?  In the example below, It asks for a double value, then another.  The first value must be less than the second value.  If not, it will ask you to enter a double that is less than the second one.  Aft..
Four values aligned to the standards of conduct in pmp : What are the four values aligned to the standards of conduct in pmp? Choose ONE of the values and provide your reasons as to why this value is essential in project voice based email for blind people.
Write paper on the mexican and american war on drugs : Write paper on the Mexican and American War on Drugs - you need to write 800 words.
Physical therapy : Looking for Microsoft Office 2013: Advanced Capstone Project 2 BJM Physical Therapy. Willing to pay whatever is needed for it completed. Need before Sunday 4/24. Anything helps, greatly appreciated.
Validate user information : Create 2 web pages that does the following: 1) Page 1: HTML Page that contains a form that collect information from user and pass it on to the next page. a) You need to validate user information (String, number, email,..)

Reviews

Write a Review

Basic Computer Science Questions & Answers

  The it manager for the only print shop in a small town in id

The IT manager for the only print shop in a small town in Idaho. The shop is connected to the internet by satellite link. Orders are received via the internet as well as by walk-ins with portable storage drives or smart phones that can transfer files..

  The software project development

Explain the need of software engineering in the software project development.

  What is the output of the following program

What is the output of the following program? Explain. #include using namespace std;void f(int i, int j) {

  What window events can a program handle

What is the paintComponent method? How is it used in Java graphics? How does a program intentionally cause the paintComponent method to execute?

  Class about effective communication

In the last portion of the paper you will provide advice to one or more of the characters in the movie about their communication. Use what you've learned in class about effective communication, and help one or more of the characters get better.

  Newly released vulnerabilities on a daily basis

The world has to deal with newly released vulnerabilities on a daily basis.  These vulnerabilities eventually lead to active exploits of systems, and it is our job as cyber security professionals to stop that from happening.

  Identification of the concept of a target audience

You are working on a new Web site for Cruzes, Inc. The Web site is aimed at providing travel information to consumers interested in cruises. When meeting with Jason, the marketing manager of Cruzes, Inc

  Write a main function that declares an array of 100 doubles

In a for loop, assign each of the doubles a random number between 0.50 and 50.00. Here's how.

  Creating flowchart of data found on employee time cards

Create a flowchart depicting the following situations: The data found on employee time cards are keyed onto a hard disk before they are processed by a computer.

  Include a description of the media used for storage

imagine one real life example of each: a multi-file volume and a multi-volume file. include a description of the media used for storage and a general description of the data in the file.

  Display the sum of the numbers entered

Design the logic (pseudocode and diagram) for a program that allows a user to continuously enter numbers until the user enters 0. Display the sum of the numbers entered.

  Sql perform the requested tasks

SQL perform the requested tasks

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd