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
malfutka [58]
3 years ago
6

The following pseudocode describes how to extract the dollars and cents from a price given as a floating-point value. For exampl

e, a price 2.95 yields values 2 and 95 for the dollars and cents.
a. Assign the price to an integer variable dollars.
b. Multiply the difference price - dollars by 100 and add 0.5.
c. Assign the result to an integer variable cents. Translate this pseudocode into a Java program. Read a price and print the dollars and cents. Test your program with inputs 2.95 and 4.35.
Computers and Technology
1 answer:
castortr0y [4]3 years ago
4 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

    Scanner input = new Scanner(System.in);

 

 double price;

 int dollars, cents;

 

 System.out.print("Enter price: ");

 price = input.nextDouble();

 

 dollars = (int) price;

 cents = (int) (((price - dollars) * 100) + 0.5);

 

 System.out.println("Dollars: " + dollars + ", " + "Cents: " + cents);

}

}

Explanation:

Ask the user to enter price

Typecast the price as int and set it to the dollars

Subtract dollars from price, multiply the difference by 100, add 0.5 to the multiplication and type cast the result as int

Print the dollars and cents

You might be interested in
What is one advantage of top-down programming design?
mojhsa [17]

Answer:

Programmers can take advantage of abstraction to focus on specific tasks.

Explanation:

When we excel in some subjects, we can do abstraction in that subject. Abstraction means you understand by the term, and you do not need details of that term. Like you say some tasks will be done by a graphic designer as a project manager, and you do not need to understand at that point what he will be doing, and that is because you can write in a word or few what is going to be the outcome. And hence, the programmers can take advantage of abstraction to focus on specific tasks. And this is the correct option.

5 0
3 years ago
Read 2 more answers
: Each individual data items of record is called a
musickatia [10]
Each individual data items of record is called field (letter A).
The client may communicate with Proxy server to use a protocol to proxy the communication between the client and the DBMS. Proxy servers lets you hide your real Ip address and replaces it with a new IP obtained from proxy server sites.

6 0
4 years ago
Programmers use an Integrated Development Environment (IDE) to write software programs, because:
Natali [406]

Answer:

A) It simplifies the process by providing a single user interface for multiple software tools.

Explanation:

6 0
3 years ago
The process of redefining the functionality of a built-in operator, such as , -, and *, to operate on programmer-defined objects
Ksenya-84 [330]

It should be noted that the process of redefining the functionality of a built-in operator to operate is known as <u>operator overloading</u>.

Operator overloading simply means polymorphism. It's a manner in which the operating system allows the same operator name to be used for different operations.

Operator overloading allows the operator symbols to be bound to more than one implementation. It's vital in redefining the functionality of a built-in operator to operate on programmer-defined objects.

Read related link on:

brainly.com/question/25487186

3 0
3 years ago
Sidney works in the accounting department. His boss just assigned him a task that involves creating budget formulas for the comp
MA_775_DIABLO [31]

In excel spreadsheets, Sidney need to consider specifying relationships between the information you have stored in your spreadsheets when creating formulas. The elements that will help you understand using spreadsheet are the constants, operators, references and functions. This will enable her to use the formulas, without hassle in spreadsheets.

3 0
3 years ago
Other questions:
  • When people need information, they typically turn to:
    7·1 answer
  • A(n) ____________________ stores copies of data or programs that are located on the hard drive and that might be needed soon in
    9·1 answer
  • What type of organizational structure would you want to use for this company (by function, by process, by product, and so on)? E
    11·1 answer
  • Differentiate among web apps, mobile apps, and mobile web apps.
    14·2 answers
  • A(n) ____ represents a particular type of object in the real world.
    7·1 answer
  • Recursion is a natural use for a _____ (stack or queue)
    13·1 answer
  • What are the disadvantages of using pointers?
    6·1 answer
  • private int product(int n) { if(n &lt;= 1) return 1; else return n * product(n-2); } What is the output when product(6) is calle
    6·1 answer
  • What will be the range of the random numbers generated by the following code snippet? rand() % 50 + 5;
    14·1 answer
  • Plzzz help i need this today :(
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!