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
Thepotemich [5.8K]
3 years ago
7

6.12.1: Return number of pennies in total. Write a function NumberOfPennies() that returns the total number of pennies given a n

umber of dollars and (optionally) a number of pennies. Ex: 5 dollars and 6 pennies returns 506.
Computers and Technology
1 answer:
Anit [1.1K]3 years ago
3 0

Answer:

public class Pennies

{

public static void main(String[] args) {

 System.out.println("Total pennies: " + NumberOfPennies(5, 6));

               System.out.println("Total pennies: " + NumberOfPennies(5));

}

public static int NumberOfPennies(int amount, int pennies) {

    int total = (amount * 100) + pennies;

   

    return total;

}

public static int NumberOfPennies(int amount) {

    NumberOfPennies(amount, 0);

    int total = amount * 100;

   

    return total;

}

}

Explanation:

- Create a function called NumberOfPennies that takes two parameters, amount and pennies

- In order to calculate the number of pennies, multiply the given amount by 100 and add the pennies. Set this result to the total and return the total.

- Since pennies parameter should be optional, overload the function NumberOfPennies so that it can take one parameter, amount. When it takes one parameter, the value of the pennies set to 0.

Inside the main, call the function with two possible scenarios

You might be interested in
You want to design a small portable computer system with memory that can be updated, but that does not lose its contents when th
garri49 [273]

Answer:

CMOS

Explanation:

CMOS stands for complementary metal oxide semiconductor.  CMOS is in the design of several types of semiconductors. in most computers there are CMOS that are powered by the PC's batteries to save the memory state of  date, time, and system setup parameters when the PC looses power. In the question above, given the specified parameters for the new system, a CMOS chip will serve perfectly

7 0
3 years ago
CSc 2720 - Data Structures: Assignment 1 [100 points] How to Submit: Turn the .java file in Folder Assignment 1 in iCollege no l
gavmur [86]
Hehehwkwjhdhebfhshshwjbrbr
5 0
3 years ago
Why doesn't the ad load ?
baherus [9]
Try refreshing the page, if not restart your device check your internet etc.
3 0
2 years ago
Read 2 more answers
Srooy but can you guys help me with this​(sorry again miss click
telo118 [61]

what miss click let me know when you got the real one      

5 0
3 years ago
To construct a histogram using excel's chart tools, choose __________ as the chart type.
CaHeK987 [17]
Column is the correct answer. Hope this helps. :)
3 0
4 years ago
Other questions:
  • Identify the correct options to complete the following passage.
    6·1 answer
  • Which of these is an advantage of using the Clipboard task pane? A. You are able to apply OLE easily. B. There are more paste op
    15·2 answers
  • if you want to present slide to fellow student or co-workers, wich productivity software should you use to create them?
    7·1 answer
  • Identify the normalized form of the mantissa in 111.01.
    14·1 answer
  • 1) Type a statement that gets an input value into variable numBers. Assume scnr already exists and numBers has been declared.
    9·1 answer
  • Write a complete program in Assembly Language: 1. Promts the user to enter 10 numbers. 2. saves those numbers in a 32 bit intege
    15·2 answers
  • If a variable uses more than one byte of memory, for pointer purposes its address is: Group of answer choices the address of the
    12·1 answer
  • 4.2 lesson practice helps plzs
    9·1 answer
  • Question 10
    14·1 answer
  • What are some limitations when it comes to testing and ensuring program quality? List at
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!