2.4 Code Practice: Question 2

Write a program that accepts a number as input, and prints just the decimal portion. Your program should also work if a negative number is inputted by the user.

Enter a number: 15.789
Sample Output
0.789

Can someone please help me with this because I’m so stuck

Answers

Answer 1

The code is in Java.

It calculates the decimal portion of a number by subtracting the integer portion from the number. It also uses if structure to check if the number is a negative one.

Comments are used to explain each line of code.

//Main.java

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 //Initialize the Scanner object to be able to get input

 Scanner input = new Scanner(System.in);

 

 //Declare the variables

 double number, decimalPortion;

 

 //Ask the user to enter a number

 System.out.print("Enter a number: ");

 number = input.nextDouble();

 

 //Get the decimal portion of the number by subtracting the integer part from the number

 decimalPortion = number - (int) number;

 

 //If the number is negative one, multiply the decimal portion with -1 to convert it to a positive value

 if(number < 0)

     decimalPortion *= -1;

 

 //Print the decimal portion

 System.out.println(decimalPortion);

 

}

}

You may see a similar question in the following link:

brainly.com/question/17132559


Related Questions

Which of the following statements are true about the growth of technology? Select 3 options. A. Individuals in the United States currently own an average of three connected devices. B. The general public began connecting to the Internet when the World Wide Web was introduced in 1991. C. By 1995, almost half of the world’s population was connected to the Internet. D. Currently, 67% of people on earth use at least one mobile device. E. The number of devices connected to the Internet of Things is expected to triple between 2018 and 2023.

Answers

Answer:

b

Explanation:

the general public began connecting to the internet when the world wide web was introduced

Answer:

The general public began connecting to the Internet when the World Wide Web was introduced in 1991.

By 1995, almost half of the world’s population was connected to the Internet.

Currently, 67% of people on earth use at least one mobile device.

Explanation:

Why does a business need to use effective strategies to find a solution for a problem?
- to thoroughly understand the problem
-to find several solutions to a problem
-to properly diagram the flow of information to solve the problem
- to find a solution that cannot be replicated​

Answers

Answer:

to properly diagram the flow of information to solve the problem

Explanation: 99% sure this is it

A business needs to use effective strategies to find a solution for a problem for several reasons. First, using effective strategies can help the business thoroughly understand the problem they are trying to solve.

What is business?

Business refers to an organization or an individual engaged in commercial, industrial, or professional activities with the aim of generating profit.

A business typically involves buying or producing goods or services and selling them for a profit to consumers or other businesses.

For a number of reasons, a firm has to adopt efficient methods to resolve a problem. First, employing successful tactics can aid a company in fully comprehending the issue at hand, as well as its underlying causes, potential effects, and potential solutions.

This may result in more focused and successful attempts to solve problems.

Second, excellent tactics can assist the company in locating and assessing a number of potential fixes for the issue, enabling them to select the ideal course of action in light of their particular requirements and circumstances.

Thus, finding a solution that can be replicated is often desirable, as it can help the business avoid similar problems in the future and streamline their operations.

For more details regarding business, visit:

https://brainly.com/question/15826604

#SPJ2

using media allows us to:
A. Contribute and create
B. Isolate ourselves from others.
C. Avoid distractions and fun
D. Be completely passive
(I will give brainlist!!!)

Answers

Answer: "Contribute and Create"

Explanation: While, yes, technology and digital media does tend to isolate us from the real world, it is a great tool for contributing to society!

Hope fixes her mistake and comes up with this list. A 2 column table with 5 rows. Column 1 is labeled Gas with entries Argon, Carbon dioxide, Nitrogen, Oxygen, Other gases. Column 2 is labeled Percentage with entries .93, .04, 78, 21, .03. She thinks it is a good idea to list the gases based on the amount of the gas found in the atmosphere from largest to smallest percentage. Which options would she need to apply to do this? Check all that apply. Use the Text option. Use the Paragraph option. Use the Header Row option. Use the Descending option. Use the Percentage Field option.

Answers

It's the last 3. I'm too tired to say anything else so here's a photo.

Complete the sentence. refers to the increasing accessibility of technology, allowing more people to access information, create content, and develop applications,​

Answers

Answer:

I'm pretty sure your answer is  democratization of technology

Explanation:

The democratization of technology refers to the process by which access to technology rapidly continues to become more accessible to more people.

Answer:

democratization of technology: the increasing accessibility of technology, allowing more people to access and create content and applications

Explanation:

edge 2022

what are super computers? what is their application in real life situation​

Answers

Answer:

A supercomputer is a computer with a high level of performance as compared to a general-purpose computer. Common applications for supercomputers include testing mathematical models for complex physical phenomena or designs, such as climate and weather, evolution of the cosmos, nuclear weapons and reactors, new chemical compounds (especially for pharmaceutical purposes), and cryptology.

When someone refers to "space" on a computer or device, they are usually referring to _____, which allows the user to save a file for future use, even after the computer has been turned off.

Answers

Answer:

Memory.

Explanation:

When someone refers to "space" on a computer or device, they are usually referring to memory, which allows the user to save a file for future use, even after the computer has been turned off.

In Computer science, a memory is a term used to describe the available space or an electronic device that is typically used for the storage of data or any computer related information such as images, videos, texts, music, codes and folders. There are basically two (2) main types of memory;

1. Read only memory (ROM).

2. Random access memory (RAM).

Answer: Secondary Storage

Explanation: Source: trust me bro

which binary number is the greatest?
11011
11001
11100
11010
11000

Answers

Answer:

the third one

Explanation:

the rest is below 28 apart from the third one which is 28 and is the most

What is the very first step that should be taken when performing work with a computer?
A. You should back up any important data.
B. You should ground yourself.
C. You should power down the system and unplug it.
D. The components should be removed.

Answers

Answer: A back up data.

Explanation:

Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer?

Answers

Answer:

ON THE TASKBAR.THE TASKBAR IS FOUND BELOW THE DESKTOP.ASK FOR FURTHER EXPLANATION.A BRAINLIEST PLEASE

Q:Ideally, how often should you back up the data on your computer? once an hour once a day once a month once a year

A: It's once a day

Answers

Answer:

Ideally you should do it once a day!

Explanation:

On edge! And it's on google too but I know it from my tests and learning!

Ideally, you should back up the data on your computer regularly, and the frequency of backups will depend on the amount and importance of the data you generate or modify.

What is backup?

Backup refers to the process of creating a copy of data and storing it in a separate location or device in case the original data is lost, damaged, or corrupted.

Ideally, you should back up your computer's data on a regular basis, with the frequency of backups determined by the amount and importance of the data you generate or modify.

It is recommended to back up critical data, such as important documents, financial records, and photos, at least once a day, and even more frequently if possible, such as hourly or in real-time.

Monthly or weekly backups may be sufficient for less critical data. The key is to have a consistent and dependable backup system in place to safeguard your data in the event of hardware failure, theft, loss, or other disasters.

Thus, this way, the data should be backed up regularly.

For more details regarding backup, visit:

https://brainly.com/question/29590057

#SPJ2

Which of these tools can best be used as a self assessment for career planning purposes? a personality test an asset analysis a self-directed learning experience a goal development checklist

Answers

Answer:

C - a self-directed learning experience

Explanation:

The tool that can best be used as a self-assessment for career planning purposes is a self-directed learning experience. Thus the correct option is C.

What is a Career?

A career is referred to what an individual chooses as a profession to earn something. A career of an individual is based on his talents, skills, and abilities which help him to seek growth and development and achieve the goals of life.

Self-directed learning encourages the organic growth of personality, creativity, persistence, and life happiness. It promotes students' options, independence, ambition, and the development of various abilities for lifetime learning.

Finding your skills, values, hobbies, and interests is the first step in the career development process. From there, one may decide what kinds of roles might be interesting to both you and a good fit.

Therefore, option C is appropriate.

Learn more about career, here:

https://brainly.com/question/2160579

#SPJ2

When connecting past and present issues, it is best to follow a series of steps. Which step is missing from the pattern? 1. Identify common issues in the past and the present. 2. Research supporting evidence. 3. __________ 4. Make connections. 5. Draw conclusions. A. Prepare an analysis report. B. Establish cause and effect. C. Validate the outcomes of the two events. D. Compose a policy to improve future issues. Please select the best answer from the choices provided A B C D

Answers

Establish Cause & Effect

Answer:

Establish Cause & Effect

Explanation:

what is one way to avoid computer-related health problems?(1 Point) a.Always use a track pad instead of a mouse. b.Position your computer so it faces a window. c.Look closely at the computer screen at all times to maintain your concentration level. d.Take frequent breaks that include moving around and stretching. Answer:__________-(/>.<)/

Answers

D. Take frequent breaks that include moving around and stretching.

PLZZ HELP!! ITS FOR A TEST!! Third generation computers were set apart because of this invention. A) microprocessors B) transistors C) integrated circuits D) vacuum tubes

Answers

Answer:

A. Invention of microprocessor

Explanation:

The third generation of computer itself was based on the technology of integrated circuits (shorten as IC).

It lasted for about 6 years and was brought to an end with the advent of the fourth generation of computers which was based on microprocessors.

Hence, option A answers the question.

Answer: I'm pretty sure the answer is C. Integrated Circuits.

Explanation: "The computers of the third generation used Integrated Circuits (ICs) in place of transistors. A single IC has many transistors, resistors, and capacitors along with the associated circuitry. The IC was invented by Jack Kilby. This development made computers smaller in size, reliable, and efficient." ( Tutorialspointwww.tutorialspoint.com)

Select the correct answer.
Ben wants to reduce the file size of an image in his document. Which feature of a word processing program will help him do so?

Answers

Answer:

COMPRESS, THIS WILL MAKE IT INTO A ZIP

Explanation:

What is authentication?
А
The process of converting data that has been converted into an unreadable form of text back to its original form
B
The process of converting data into an unreadable form of text
С
O
The process of verifying the identity of a user who logs on to a system, or the integrity of transmitted data
D
The process of providing proof that a transaction occurred between identified parties

Answers

Answer:

C

Explanation:

I believe that's the answer if it's not sorry

Which of the following best describes the difference between software and hardware?


A Hardware is the outside of the computer; software is the material on the inside of a computer.

B Hardware is the material produced by the computer like a business letter; software is the information in the computer.

D Hardware is the equipment; software is the instructions given to the equipment in order for the equipment to perform a task.

C Software is the equipment; hardware are the programs that run the software.

Answers

Answer:

D. Hardware is the equipment; software is the instructions given to the equipment in order for the equipment to perform a task

Explanation:

Hardware is the actual part while Software is the program that operates the Hardware

A _____ describes two or more computers connected to each other.

computer network

client

server

switch

Answers

Answer:

Computer network.

Since it is 2 or more computers connected together.

Its a Computer Network because 2 or more computers are connected through the same network.
Thank You!

ASAP
Which of the following explains why giving directions to a location is suitable for creating an algorithm?
1. An algorithm provides step-by-step instructions.
2. An algorithm is written in computer code.
3. An algorithm gives different steps each time it is used.
4. An algorithm posts directions on a website.

Answers

Answer:

The answer is A

Explanation:

al·go·rithm

noun

a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

"a basic algorithm for division"

(a step-by-step tutorial or guide)

Answer:

A

Explanation:

ASAP please
What is an algorithm?
1. a way to make an informed judgment
2. used only on a computer
3. used only with map directions
4. a set of directions for problem solving

Answers

I think it’s 4


a process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.

Answer:

Answer is D :)

Explanation:

2. What is the name for an action performed by the VR Robot?
3. Command
b. Behavior
o. Parameter
d. Programming Language

Answers

Answer:

I think is o but I know the vr robot is work to help human and thinks like that hope you I help you I know my answer is short but this what I can to help you with

What is the analysis stage in System development life cycle?

Answers

Answer:

Explanation:

end user business requirements are analyzed and project goals converted into the defined system functions that the organization intends to develop. The three primary activities involved in the analysis phase are as follows: Gathering business requirement. Creating process diagrams.

Which of the following is a unique feature of Object-oriented programming?
O They have syntax.
O They are web-based.
O They use objects that contain data and functions.
O They are interpreted by compilers into binary machine language.

Answers

Answer:

the answer is they used objects that contain data and function ( code)

Answer:

answer is C :)

Explanation:

how do you get people to add you?

Answers

Answer:

go to their profile and click the person icon and done

Explanation:

A person with a kinesthetic learning style learns best by
a. reading and writing.
b. moving around and interacting with objects.
c. working with numbers and patterns.
d. independent study.

Answers

B. Moving around and interacting with objects. Is the answer

A student builds a model of her bedroom. The scale is 1:25. In the scale model, the students bed is 3 inches long. How long is the students actual bed?

Answers

Answer:

The student’s actual bed is 75 inches long

Explanation:

Here in this question, we want to find out the length of the student’s actual bed.

The ratio of the model to the real is 1:25

Let the actual length of the bed be x inches

Thus;

1/25 = 3/x

By cross multiplying

1 * x = 3 * 25

x = 75 inches

What is the main purpose of broadcasting via satellite? A. To enable signal reception at night B. To convert analog signals to digital signals C. To enable signal reception over a wider area D. To strengthen and improve the quality of the signal

Answers

Answer:

The answer is "Option C".

Explanation:

Satellite transmission is a content distribution program, that utilizes digital signals to transmit from satellites that receive parabolic antennas widely known as satellite dishes. It's a  low noise block generator for transmitted to cooling. It also allows the user it accepts single in a wide area, and the wrong choice can be defined as follows:

In choice a, It allows the uses to receive a signal at all times, that's why it is wrong. In choice b, It provides digital signals,  that's why it is wrong. In choice d, It is wrong because it always provides quality signals.  

 

Hi, I just have a few questions from my digital tech assignment.

1. ___ domain indicates that the computer or DNS name does not exist.

2. Why are users able to log on to any computer in a domain?

A. because they do not need an account for each computer
B. because all computers act as workstations and servers
C. because they can reconfigure or update hardware without turning off the system
D. because networks use names to make accessing nodes easier

3. Describe, step by step, how to create an account for a computer on the domain controller.

Answers

Answer:

b

Explanation:

i took the test my self

Answer:

for number one you put system in the blank

Explanation:

What were precomputed tables and why were they necessary?​

Answers

Yesterday’s comment is a good idea to have you on in your life if I can find a good job in the world of the control you can get in your life if you’re a real life or you can get your own job

Precomputation in algorithms refers to the act of running an initial computation ahead of run time to create a lookup table that may be used by an algorithm to avoid running the same computation repeatedly each time it is executed.

What is algorithm?

An algorithm is a process used to carry out a computation or solve a problem. In either hardware-based or software-based routines, algorithms function as a detailed sequence of instructions that carry out predetermined operations sequentially.

Algorithms are procedures for resolving issues or carrying out tasks. Algorithms include math equations and recipes.

Algorithms are used in programming. All online searching is done using algorithms, which power the internet.

The term "precomputation" in the context of algorithms refers to the act of performing an initial computation before the algorithm is actually used.

This creates a lookup table that the algorithm can utilise to avoid performing the same computation repeatedly each time it is used.

Thus, this way, precomputed tables are essential.

For more details regarding algorithm, visit:

https://brainly.com/question/22984934

#SPJ2

Other Questions
Researchers used a CT scan to reexamine King Tut's body. What were the effects of this new technology? Choosethree answers.It provided new information.It proved an error in an old conclusion.It damaged the remains of Tut's body.It failed to give additional information.It showed something that had been overlooked. Carter Pearson is a partner in Event Promoters. His beginning partnership capital balance for the current year is $55,700, and his ending partnership capital balance for the current year is $62,700. His share of this year's partnership income was $5,950. What is his partner return on equity based on the law of suspects do you think the committee of public safety protected the revolution from its enemies Yo____ jugar en el campo -prefiero -prefieres -prefiere can you please help me 2. Part A: What does the word "haunt" most closely mean in paragraph 20? A: a place where a specific group of people used to stay B : a large amount of weapons C: a section of the desert that is difficult to find D: a frichtening area filled with ghosts Part B: Which of the following phrases from paragraph 20 best support the answe to Part ABut in the way of all wars, the fight against terrorism spawned unintended consequences. For one thing al-Qaeda and other extremist Islamist groups proved to have deep roots. Crushed in their original haunts in the Middle East and unable to repeat their attacks on the US, many terrorists have moved their operations to Western Europe where they attacked British, French German and Spanish civilians PLEASE HELP ALGEBRA 2!! The paintings in the Lascaux Cave contain mostly images of what? Find all numbers such that 18 plus 4 times the number is less than 30. Explain how the phrase "correlation does not imply causation" is relevant to studying the results of correlational studies as compared to experimental studies. A jet plane can travel 567 miles per hour. How many mile can it travel in 4hour During the first trip and 6 Hour during the scon trip If h(x) = x 10, find h(2). (1 point)201.610 Help me please and thank you Whats is ittttt I neeed helppp what climates are characterized by low humidity? describe the main difference between old immigration prior to civil war and New immigration during the gilded age Convert 17.8 miles to km A cube has a surface area of 54 square centimeters, what is the side length? What motivates Mr. Spencer to show a courteous but not too intelligent interest in the new safe and vault? what is one way to avoid computer-related health problems?(1 Point) a.Always use a track pad instead of a mouse. b.Position your computer so it faces a window. c.Look closely at the computer screen at all times to maintain your concentration level. d.Take frequent breaks that include moving around and stretching. Answer:__________-(/>.