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");}}

Respuesta :

Answer:

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

Following are the complete code to the given question:

Program Explanation:

  • Defining a class "AssigningSum".
  • Inside the class defining the main method, inside this "numCoins, numNickels, and numDimes" integer variable is declared.
  • In the "numNickels, numDimes" it initializes the integer value, use a formula that adds (numNickels+numDimes) value into the numCoins, and prints its value with the message.

Program:

public class AssigningSum //defining a class AssigningSum

{

   public static void main (String [] args) //defining main method

   {

       int numCoins,numNickels, numDimes;//defining integer variable

       numNickels = 5;//initializes the value into integer variable

       numDimes = 6;//initializes the value into integer variable

       //require code

       numCoins = numNickels + numDimes;//adding (numNickels+numDimes) value in to the numCoins

       System.out.print("There are ");//print message

       System.out.print(numCoins);//print added value

       System.out.println(" coins");//print message

       numNickels = 9;//initializes the value into integer variable

       numDimes = 0;//initializes the value into integer variable

       numCoins = numNickels + numDimes;//adding (numNickels+numDimes) value in to the numCoins

       System.out.print("There are ");//print message

       System.out.print(numCoins);//print added value

       System.out.println(" coins");//print message

   }

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/6030677

Ver imagen codiepienagoya