1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AnnZ [28]
3 years ago
8

Write a JAVA program that repeatedly prompts your user for a number, uses a recursive function to calculate the product of that

number times three (3), and displays the product. Select a sentinel value that allows your user to quit. Do NOT use the multiplication operator (*) in your proposed solution.

Computers and Technology
1 answer:
polet [3.4K]3 years ago
6 0

Answer:

// Scanner class is imported to receive user input

import java.util.Scanner;

// class Solution is defined  

public class Solution{

   // recursive function to calculate  

   // multiplication of two numbers

   // the second number is initialised to 3

   // it return the product

   public static int product(int x, int y)

   {

       // first it check if 3 is not 0

       // then it uses repetitive addition to get the product

       // it continues till 3 becomes 0

       if (y != 0)

           return (x + product(x, y - 1));

   }

     

   // main method to begin program execution

   public static void main (String[] args)

   {

       // Scanner object scan is initialize to receive input

       // via keyboard

       Scanner scan = new Scanner(System.in);

       // prompt is display to user to enter number

       System.out.println("Enter your number to multiply: ");

       // user input is assigned to x

       int x = scan.nextInt();

       // 3 is assigned to y which specify the number of times to multiply

       int y = 3;

       // while loop that continue to receive user input as long as it is not -1

       while(x != -1){

           // The result of the product is displayed

           System.out.println(product(x, y));

           // prompt is display to user to enter number

           System.out.println("Enter your number to multiply: ");

           // user input is assigned to x

           x = scan.nextInt();

       }

       

   }

}

Explanation:

The program is written in Java. An image of program output when the code is executed is attached.

A Scanner class is imported that allow program to read input. Then the product method is defined that compute the product of a number3 times using repetitive addition.

Then the method product is called inside the main method where the user is asked to continue input a number as long as the sentinel value (-1) is not entered.

You might be interested in
Can someone please answer this for me I will answer one of yours.
julsineya [31]
4 is preview i think.
4 0
4 years ago
Modify this query so results are grouped by values in the DeptName field and values in the Credits field are summarized with the
docker41 [41]

Answer:

Select and group the table with the DeptName and sum the credits field from the Design Ribbon tab, click the Totals button, then click the credits field's total row, expand the Total row's Group by list, and select the Sum option and then click run.

Explanation:

Microsoft Access is a relational database platform developed by Microsoft. It is used to create a database for storing data and a means of querying the data from storage.

The result of the query can be a grouped dataset, grouping a column by the aggregate of another column. The dataset above is queried to return the grouped DeptName by the aggregate of the sum of the credits field.  

7 0
3 years ago
When enter a function or formula in a cell, which is the character you must type?
vladimir1956 [14]
The answer is A. For instance, to use the sum function, you would need to =SUM()
7 0
4 years ago
Your team has been asked to design a LAN for a very successful CPA firm with five departments in one building and a total of 560
ziro4ka [17]

Answer:

Please find in attachment.

Explanation:

The details in attachment are self explanatory.

Download docx
5 0
3 years ago
What is the significant feature of computer capabilities?​
Pepsi [2]
<h2>Hey mate </h2><h2>Here is ur answer..! ⬇️⬇️</h2>

Explanation:

<u>The characteristics of computers that have made them so powerful and universally useful are speed, accuracy, diligence, versatility and storage capacity. Let us discuss them briefly. Computers work at an incredible speed.</u>

<em><u>Hope</u></em><em><u> </u></em><em><u>it helps</u></em><em><u> </u></em><em><u>u plzz</u></em><em><u> </u></em><em><u>mark it</u></em><em><u> </u></em><em><u>as brainalist</u></em><em><u> </u></em><em><u>and thnk</u></em><em><u> </u></em><em><u>my answers</u></em><em><u> </u></em>

4 0
3 years ago
Other questions:
  • I want to make a if else statement where I want to make a message. If the input are letters (which it’s not supposed to) then I
    14·1 answer
  • Which of the following is true regarding Moore’s Law? A.) explained the growth in computing capabilities between 1965 and 1995 B
    14·1 answer
  • What is plagiarism?<br> EXPLAIN IT
    15·2 answers
  • What is the process called if you are erasing data on your hard drive from a MAC
    12·1 answer
  • Negative glue effects
    8·1 answer
  • Care sunt avantajele fișierelor de tip ".pdf" ?
    15·2 answers
  • Which of the following, (1) money deposited in a bank account, (2) student recording her answer to a question in an online test,
    14·1 answer
  • When installing EMT conduit that will be exposed to wet conditions, _______ fittings should be used.
    5·2 answers
  • Consider the following code snippet:
    10·1 answer
  • 1. Haruto was a programmer working in the early 2000s. Which kind of program or language was
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!