Ask Question

Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes results in 11 coins. Note: These activities may test code with different test values. This activity will perform two tests: the first with nickels = 5 and dimes = 6, the second with nickels = 9 and dimes = 0. import java. util. Scanner; public class AssigningSum {public static void main (String [] args) {

int numCoins; int numNickels; int numDimes; numNickels = 5; numDimes = 6; / * Your solution goes here * / System. out. print ("There are "); System. out. print (numCoins); System. out. println (" coins"); }}

+4
Answers (1)
  1. 28 March, 07:42
    0
    The statement that assigns the sum of numNickels and numDimes to numCoins is as follows:-

    numCoins = numNickels + numDimes;

    System. out. print ("There are "); System. out. print (numCoins); System. out. println (" coins");

    numNickels = 9;

    numDimes = 0;

    numCoins = numNickels + numDimes;

    System. out. print ("There are "); System. out. print (numCoins); System. out. println (" coins");

    Explanation:

    The first statement in the solution adds the values of numNickels (6) and numDimes (11), the rrsult is then saved in numCoins variable

    The next line prints the value of numCoins (17) alongside some strings

    The next line assigns 9 to numNickels

    The next line assigns 0 to numDimes

    The next line adds the values of numNickels (9) and numDimes (0), the result is then saved in numCoins variable

    The next line prints the value of numCoins (9) alongside some strings
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes results in 11 coins. Note: These activities ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers