Answer:
The Java code is given below with appropriate variable names for better understanding
Explanation:
import java.util.Random;
import java.util.Scanner;
public class MultiplicationQuestions {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Random rand = new Random();
int n1, n2, result, total = 0, correct = 0;
char ch = 'y';
while(ch == 'y'){
n1 = 1 + rand.nextInt(9);
n2 = 1 + rand.nextInt(9);
System.out.print("What is "+n1+" * "+n2+" ? ");
result = scan.nextInt();
if(result==n1*n2){
System.out.println("Correct. Nice work!");
correct++;
}
else{
System.out.println("Incorrect. The product is "+(n1*n2));
}
System.out.print("Want more questions y or n ? ");
ch = scan.next().charAt(0);
total++;
}
System.out.println("You scored "+correct+" out of "+total);
}
}
Answer:
Thank you! can i have brainliest please?
Explanation:
Answer:
grad_age=matric_age+4
Explanation:
As mention in the question their are two variable matric_age and grad_age respectively .The grad_age variable store the value of 4 more than that of matric_age i.e (matric_age+4) means that it store the value 4 plus matric_age Suppose a matric_age is initialized with 4 then value of grad_age=4+4=8.
Answer:
Argentina se creó tras su independencia respecto de España el 9 de julio de 1816, tras 6 años de guerra por la independencia del país, donde líderes como Manuel Belgrano, Martín Miguel de Güemes y José de San Martín derrotaron a los españoles.
La unidad nacional de los argentinos, a su vez, se originó tras las invasiones inglesas de 1806 y 1807, y se consolidó tras la conquista de España por parte de los Bonaparte, que dio origen a la Revolución de Mayo de 1810, donde los argentinos decidieron imponer un gobierno propio.
Answer:
The program to this question as follows:
Program:
//header file iostream
#include<iostream> //including file for use basic function
//using name space
using namespace std;
//main method
int main() //defining main method
{
int a[3][3]; //defining two dimension array
int x,y,sum=0; //defining variables
cout<<"Enter array elements: "<<endl; //message
for(x=0;x<3;x++) // for row
{
for(y=0;y<3;y++) //for column
{
cin>>a[x][y]; //input values from user.
}
}
//loop for calculting sum.
for(x=0;x<3;x++)
{
for(y=0;y<3;y++)
{
sum=sum+a[x][y];//add all elements
}
}
cout<<"Sum: "<<sum; //print sum.
return 0;
}
Output:
Enter array elements:
1
2
3
4
5
6
7
8
9
Sum: 45
Explanation:
In the above C++ programming language code first, a header file is included then the main method is declared, inside a main method 2D array that is "a[][]", and an integer variable is defined that are "i, j, and sum". In the next line for loop is used, this loop is used two times that can be described as follows:
- The first time it is used for inserting elements from user ends.
- The second time, it uses the sum variable to add all array elements. and in the last print function that is "cout" is used for print sum variable value.