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
SUMMING THE TRIPLES OF THE EVEN INTEGERS FROM 2 THROUGH 10) Starting with a list containing 1 through 10, use filter, map and su
Anestetic [448]

Answer:

numbers=list(range(1,11)) #creating the list

even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()

triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map

total_triples=sum(triples) #calculatting the sum

numbers=list(range(1,11)) #creating the list

even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension

triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension

total_triples=sum(triples) #calculating the sum.

Explanation:

Go to the page where you are going to write the code, name the file as 1.py, and copy and paste the following code;

numbers=list(range(1,11)) #creating the list

even_numbers=list(filter(lambda x: x%2==0, numbers)) #filtering out the even numbers using filter()

triples=list(map(lambda x:x*3 ,even_numbers)) #calculating the triples of each even number using map

total_triples=sum(triples) #calculatting the sum

numbers=list(range(1,11)) #creating the list

even_numbers=[x for x in numbers if x%2==0] #filtering out the even numbers using list comprehension

triples=[x*3 for x in even_numbers] #calculating the triples of each even number using list comprehension

total_triples=sum(triples) #calculating the sum

7 0
4 years ago
A security utility program that scans the system for small programs that interfere with how a computer functions are _____ utili
Aneli [31]

Answer:

A security utility program that scans the system for small programs that interfere with how a computer functions are _____ utilities.

Explanation:

7 0
3 years ago
Please help me!! 10 Points are waiting!!
prisoha [69]

Google

https://google.com

Google has a large index of keywords and where those words can be found. Google uses a trademarked algorithm called PageRank, which assigns each Web page a relevancy score.

3 0
3 years ago
Battery maker Duracell introduced a new product called the Duracell Powermat, which is a wireless charging pad for mobile device
lapo4ka [179]

Answer:

<em>Brand Extension </em>

Explanation:

Brand extension is using a brand name for a new product or class of product or service.

A brand extension takes advantage of a well-known product's prestige and success to start a new product.

There must be a logical link between the original product and the new item to be effective. The opposite effect, product dilution, may result from a weak or non-existent relationship.

7 0
3 years ago
What is a technology?​
Leokris [45]

Answer:

The definition of technology is science or knowledge put into practical use to solve problems or invent useful tools

                                                    OR

Technology is the sum of techniques, skills, methods, and processes used in the production of goods or services or in the accomplishment of objectives, such as scientific investigation

7 0
3 years ago
Other questions:
  • What is an image that you can apply to another image to add detail and texture?
    6·1 answer
  • Which best explains a password attached to a document
    9·1 answer
  • Define full-duplex. Group of answer choices term used to describe the networking device that enables hosts in a LAN to connect t
    9·1 answer
  • A security manager has discovered that sensitive information stored on a server has been compromised. The organization is requir
    7·1 answer
  • Which of these identifies the intersection of row 16 and column D?
    14·1 answer
  • An option already selected by windows is called____ ( default option/ default selection)​.
    6·1 answer
  • Using only AND, OR and inverter gates to implement the above Boolean equation, how many gates are needed
    8·1 answer
  • POR FAVOR AYUDENME DIGAN SOLO 10 Ejemplos de Software de Sistema. SI NO REPRUEBO Y LE DOY CORONA
    14·2 answers
  • A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of cust
    15·1 answer
  • A market-product strategy that requires no change in the basic product but instead seeks new buyers is known as ______
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!