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
ivanzaharov [21]
3 years ago
6

What is the problem with the code snippet below? public class Test { public static void main(String[] args) { System.out.println

(cost(10, 4)); } public static void cost(int price, int reps) { for (int i = 0; i < reps; i++) { System.out.print(price); } } }
Computers and Technology
1 answer:
FrozenT [24]3 years ago
6 0

Answer:

The problem in the following snippet is that the function "cost" returns the void and it cannot used as the expression in the print statement

Explanation:

public class Test

{

    public static void main(String[] args)

    {

          System.out.println(cost(10, 4));

     }

     public static void cost(int price, int reps)

     {

           for (int i = 0; i < reps; i++)  

           {

                   System.out.print(price);                

           }  

     }

}

Output:

Main.java:4: error: 'void' type not allowed here

        System.out.println(cost(10, 4));

                               ^

1 error

In the following code the void type is not allowed in the function "cost".

You might be interested in
____ is the use of networking technology to provide medical information and services.
Cerrena [4.2K]
Answer: WebMD

WebMD, with the URL https://www.webmd.com, provides credible health and medical information on the web.
3 0
3 years ago
Your manager has asked you to write a program that displays the percentage of males and female in your class. The program should
Blababa [14]

<u>Explanation:</u>

The program using <em>python programming language </em>would be:

First, we write the Input prompt.

<u>Input  prompt for the user</u>

number_of_males_in_class = int (input ('Enter the number of males: '))

number_of_females_in_class = int(input('Enter the number of females: '))

Next, we write the Process algorithm.

<u>Process  algorithm</u>

total_number_of_students_in_class = number_of_females_in_class + number_of_males

_in_class

percentage_of_males_in_class = number_of_males_in_class / total_number_of_students

_in_class

percentage_of_females_in_class = number_of_females / total_number_of_students

Finally, the Output process

<u>Output process</u>

print('Total number of males in class =', format(percentage_of_males_in_class, '.0%'))

print('Total number of females =', format(percentage_of_females_in_class, '.0%'))

7 0
3 years ago
Considering all of the time and effort that is put into creating an online business, it is in a merchant’s best interest to make
givi [52]

Search engine optimization will help increase the number of clicks on the business' website and help to drive the sales by targeting the appropriate audience for buying the products.

<h3>What is search engine optimization?</h3>

Search engine optimization, or SEO, is one of the most important functions of the generation of organic clicks on the website for an online ecommerce business.

It helps in creating a brand awareness, the costs of advertising are much lower, and also helps in improving the experience of the customers of ecommerce site.

Hence, the uses of search engine optimization in online business are as aforementioned.

Learn more about Search Engine Optimization here:

brainly.com/question/14850803

#SPJ1

4 0
2 years ago
When creating loyal customers you must develop all of the following except: a. Smooth relationships b.customer marketing c. Dedi
bixtya [17]

Answer: I think a

Explanation: sorry I’m in wrong, have a great day!! :D

7 0
3 years ago
Read 2 more answers
A fast-food restaurant has four kinds of employees:
Marysya12 [62]

Answer:

Following is given the detailed solution of the given question.

I hope it will help you!

Explanation:

7 0
3 years ago
Other questions:
  • What is PHP language
    12·1 answer
  • An administrator has noticed that GPO containing new update settings has not yet applied to one of the computers on the network.
    5·1 answer
  • Which two technologies support the building of single-page applications? and are two technologies helpful in building single pag
    12·1 answer
  • Along with an ip address, a subnet mask, and a name server, the other thing required for a computer to operate on a network is a
    15·1 answer
  • Which two statements are true about the Data Sync functionality? (Choose two.)
    15·1 answer
  • As an experienced networking professional, you are asked to conduct a posture assessment on a local credit union’s network. The
    12·1 answer
  • How do i confirm my email address on here
    7·2 answers
  • PLEASE I NEED HELP PLEASE PLEASE<br> Which function prompts the user to enter information?
    9·1 answer
  • Which of the following is not an advantage of e-commerce for consumers?
    13·2 answers
  • Write a program which will -
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!