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
Naya [18.7K]
4 years ago
12

Write a program to input money in cents from user, example 12745 and display the one dollar bills and the cents. Submit source c

ode.
Computers and Technology
1 answer:
ira [324]4 years ago
6 0

import java.util.*;  //This is used to import the Scanner

class Main {

 public static void main(String[] args) {

   System.out.println("Hello world!");

   Scanner ValCents = new Scanner (System.in);

   System.out.println("Enter Number:");

   int user_input = ValCents.nextInt();

   int result = user_input/100;  // This one will solve for the one dollar bills.

   int remain = user_input % 100;  // This one will get the remainder of cents.

   System.out.println(result + " One Dollar Bills");

   System.out.println(remain + " Cents");

 }

}

Remember that you need to get the amount of dollar bills separately from the number of cents. This is because the int variable will always return the whole value of the number. The modulo is used to get the variable of the cents as the whole number is already taken by the "result".

You might be interested in
When do you need to use a fully qualified url in a hyperlink?
Rudiy27
When you're linking to another web site.
7 0
3 years ago
C++
Sonbull [250]

Answer:

#include <iostream>

#include<iomanip>

using namespace std;

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon)

{

  double dollarCost = 0;

  dollarCost = (dollarsPerGallon * drivenMiles) / milesPerGallon;

  return dollarCost;

}

int main()

{

  double miles = 0;

  double dollars = 0;

  cout << "Enter miles per Gallon   : ";

  cin >> miles;

  cout << "Enter dollars per Gallon: ";

  cin >> dollars;

  cout << fixed << setprecision(2);

  cout << endl;

  cout << "Gas cost for 10 miles : " << DrivingCost(10, miles, dollars) << endl;

  cout << "Gas cost for 50 miles : " <<DrivingCost(50, miles, dollars) << endl;

  cout << "Gas cost for 400 miles: "<<DrivingCost(400, miles, dollars) << endl;

  return 0;

}

Explanation:

  • Create a method definition of DrivingCost that accepts  three input double data type parameters drivenMiles,  milesPerGallon, and dollarsPerGallon and returns  the dollar cost to drive those miles .
  • Calculate total dollar cost and store in the variable, dollarCost .
  • Prompt and read the miles and dollars per gallon  as input from the user .
  • Call the DrivingCost function three times  for the output to the gas cost for 10 miles,  50 miles, and 400 miles.

 

8 0
3 years ago
Read 2 more answers
Observe the following statements and decide whether the variable result’s value is TRUE or FALSE.
devlian [24]

Answer:

    result 1 = false;

     result 2 = true;      

Explanation:

result 1 = (43 < -77 && 1! = 10)

            43 < -77 = false

             1 != 10 = true

for any false && true logical operator, it returns false

    result 1 = false;

 false = 90 < -77 || -1 < 43

              90 < -77 = false

                -1 < 43 = true

for any false || true logical operator, it returns true

  result 2 = true;      

5 0
3 years ago
Which tab should you click if you want to access the Show All Comments option in a worksheet?
Lostsunrise [7]

Answer: Review

Because you want to review the comments

3 0
3 years ago
Read 2 more answers
Answer will be marked brainliest
zhuklara [117]

Answer:

Normal laptop screen repair services cost AED 350 to AED 950 i think...

5 0
3 years ago
Other questions:
  • âwhen the footer is the last element in a page body, the _____ pseudo-element is used to add a placeholder element after the foo
    8·2 answers
  • ________ is the amount of data that can be transmitted across a transmission medium in a certain amount of time.
    15·1 answer
  • I need help <br> Match each words with its definition!!!<br> Please helpppppppp
    12·1 answer
  • Consider the following high-level recursive procedure: long long int flong long int n, long long int k long long int b b k+2; if
    9·1 answer
  • Assume that month is an int variable whose value is 1 or 2 or 3 or 5 ... or 11 or 12. Write an expression whose value is "jan" o
    10·1 answer
  • What does a converter do? A. It converts one technological system into another. B. It converts one type of electrical signal int
    10·2 answers
  • What is a header row?
    8·1 answer
  • Consider the following method, which is intended to return the number of local maximum values in an array Local maximum values a
    6·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
  • What is a major advantage of medical simulators?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!