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
Aleksandr-060686 [28]
3 years ago
11

Square a Number This is a practice programming challenge. Use this screen to explore the programming interface and try the simpl

e challenge below. Nothing you do on this page will be recorded. When you are ready to proceed to your first scored challenge, click "Finish Practicing" above. Programming challenge description: Write a program that squares an integer and prints the result. Input: Your program should read lines from standard input. Each line will contain a positive integer. Output: For each line of input, print to standard output the square of the number. Print out each result on a new line.
Computers and Technology
1 answer:
yan [13]3 years ago
3 0

Answer:

import java.io.*;

public class Main {

  public static void main(String[] args) throws IOException {

      BufferedReader brObject = new BufferedReader(new InputStreamReader(System.in));

      String str;

      while ((str = brObject.readLine()) != null) {

          int number = Integer.parseInt(str);

          System.out.println(number * number);

      }

  }

}

Explanation:

  • Inside the main method, create an object of BufferedReader class to read lines from standard input.
  • Declare a string and run a while loop until it reaches the end of the input.
  • Inside the while loop convert the string into an integer data type.
  • Finally display the output by squaring the number.
You might be interested in
Explain the role of ANY TWO components of the CPU
mars1129 [50]

Answer:

An <u>arithmetic logic unit</u> (ALU) is a digital circuit used to perform arithmetic and logic operations.

<u>The control unit</u> of the central processing unit regulates and integrates the operations of the compute

8 0
2 years ago
Which is the most visual social media site?
Aleks04 [339]
Enge extrapolated this analysis across the 2.2 billion<span> users on Google and concluded that while the “active profiles” on Google+ amount to </span>111 million<span> users, only 6.7 million users have 50 or more posts ever, and only 3.5 million have 50 or more posts in the last 30 days</span>
3 0
3 years ago
Create an application that lets the user enter the food charge for a meal at a restaurant. When a button is clicked, the applica
Art [367]

Answer:

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

       Dim foodCharge, tax, tip, totalCharge As Double

       foodCharge = Val(TextBox1.Text)

       tax = 0.07 * foodCharge

       tip = 0.15 * 100

       totalCharge = foodCharge + tax + tip

       Label5.Text = tax

       Label6.Text = tip

       Label7.Text = totalCharge

   End Sub

End Class

Explanation:

  1. This is implemented using Visual Basic programming language
  2. Firstly we declared all the variables using DIM key word
  3. Then the calculation for each variable is done according to the specification of the question
  4. On the form (See attached Image) the controls for receiving the user input is created as well as the controls for the output.
  5. See the attached sample run below:

4 0
4 years ago
1. How fast do human beings walk?
zepelin [54]

Answer:

a.about 3 or 4 miles per hour

8 0
3 years ago
Read 2 more answers
You want to view a list of users on a linux system. what command should you use?
vredina [299]
Answer is A: cat /use/passwd
7 0
2 years ago
Other questions:
  • Analog footage can be digitized using video _____ equipment.â
    7·1 answer
  • Gary lives in an area that receives a lot of rain throughout the year. which device would be useful to him to maintain his compu
    8·1 answer
  • Study the following two class interfaces: class Question { public: Question(); void set_text(string new_text); void set_answer(s
    11·1 answer
  • describe at least five ways in which information technology can help studying subjects other than computing​
    6·1 answer
  • 1) APPLICATION BASED QUESTION:-
    5·1 answer
  • Henry is planning to visit Spain for a vacation. He wants to learn Spanish, but he prefers to do it in a fun way. He searches on
    8·2 answers
  • Join my me et.goo gle.etj-dovn-kds​
    11·1 answer
  • Free pass if you want it.
    12·2 answers
  • Who knows my sister better?
    15·2 answers
  • Body LanguageWhat are the nonverbal communications mentioned in the video? And how the video explained the meaning of these?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!