Question

Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes...

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. See How to Use zyBooks.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

import java.util.Scanner;
public class AssigningSum
{
   public static void main(String[] args) {
   int numCoins;
   int numNickels;
   int numDimes;
  
   numNickels = 5;
   numDimes = 6;
  
   numCoins = numNickels + numDimes;
  
       System.out.print("There are ");
       System.out.print(numCoins);
       System.out.print(" coins");
   }
}

6 7 8 Main.java Assigning Sum.java: 1 import java.util.Scanner; 2 public class Assigning Sum 3-{ 4 public static void main(St

Your code produce error due to spelling mistake of numNickels in line number 12 ,It should be numNickels instead of numNickles

Note :If you find any error in the above code it may be due to improper indentation occurred while copying the code ,so please provide proper indentation with the help of attached screenshot with the answer. Also make sure that your name of file should be same as your class name (here it is AssigningSum).

If you find my answer helpful,please give thumbs up,Thank you

Add a comment
Know the answer?
Add Answer to:
Write a statement that assigns numCoins with numNickels + numDimes. Ex: 5 nickels and 6 dimes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write three statements to print the first three elements of array runTimes. Follow each statement with...

    Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array. See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as runTimes[9] for a 5-element array, the test...

  • CGALLENE 4.2: More syntax errors. ACTIVITY Each cout statement has a syntax error. Type the first...

    CGALLENE 4.2: More syntax errors. ACTIVITY Each cout statement has a syntax error. Type the first cout statement, and press Run to observe the error message. Fix the error, and run again. Repeat for the second, then third, cout statement cout << "Num: "<< songnum << endl; cout << int songNum << endl; cout << songNum " songs" << endl; Note: These activities may test code with different test values. This activity will perform two tests: the first with songNum-5,...

  • in java Feedback? CHALLENGE ACTIVITY 5.2.2: Printing array elements. Write three statements to print the first...

    in java Feedback? CHALLENGE ACTIVITY 5.2.2: Printing array elements. Write three statements to print the first three elements of array run Times. Follow each statement with a newline. Ex: If runTime = (800,775, 790, 805, 808) print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5 element array. See 'How to Use zyBooks". Also note: If the submitted code tries to access an invalid array...

  • A jar contains 3 pennies, 5 nickels and 2 dimes. A child selects 2 coins at...

    A jar contains 3 pennies, 5 nickels and 2 dimes. A child selects 2 coins at random without replacement from the jar. Let X represent the amount in cents of the selected coins 8:01 АА A ohm.lumenlearning.com Ajar contains 3 pennies, 5 nickels and 2 dimes. A child selects 2 coins at random without replacement from the jar. Let X represent the amount in cents of the selected coins. Find the probability X = 10. Find the probability X =...

  • C programming only please 5.2.3: Printing array elements with a for loop. Write a for loop...

    C programming only please 5.2.3: Printing array elements with a for loop. Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = NUM_VALS - 1. (Notes) Note: These activities may test code with...

  • CHALLENGE ACTIVITY CCY7.10.5: Read user input and print to output. Assign user_str with a string from...

    CHALLENGE ACTIVITY CCY7.10.5: Read user input and print to output. Assign user_str with a string from user input, with the prompt: 'Enter a string:" Hint- Replace the ? in the following code: user_str?('Enter a string: ') Note: These activities may test code with different pre-entered test values, thus blank print statements are placed after the prompt so that output will appear on the following line. This activity will perform two tests: the first with user input of "Hello", the second...

  • Unreachable statement??????? CSIT 111 home> 313: More string operations E zyBooks catalog Print 'Censored if userinput...

    Unreachable statement??????? CSIT 111 home> 313: More string operations E zyBooks catalog Print 'Censored if userinput contains the word 'darn, else print userinput. End with newline Note: These activities may test code with different test values. This activity will perform three tests, with userinput of That darn cat', then with Dang, that was scary!", then with I'm darning your socks.. See How to Use zyBooks . Also note: If the submitted code has an out-of-range access, the system will stop...

  • Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...

    Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40: 20 10 5 2 1 Note: These activities may test code with different test values. This activity will perform four tests, with userNum = 40, then with userNum = 2, then with userNum = 0, then with userNum = -1. See "How to Use zyBooks". Also note: If the submitted code has an...

  • Write an expression that executes the loop while the user enters a number greater than or...

    Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with userNum initially 9 and user input of 5, 2, -1, then with userNum initially 0 and user input of -17, then with userNum initially -1. See "How to Use zyBooks". . Also note: If the submitted code has an infinite loop, the system will...

  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to...

    Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40), then newScores = {20, 30, 40, 10). Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int oldScores[4]). See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as newScores[9] for a 4-element...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT