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](https://us-static.z-dn.net/files/d7c/ab979cc21f61ac0b433a3c2f9e6107fc.jpg)