Answer:
There were 16 bags of lollipops and 17 of tootsie
Explanation:
In the problem it says "Ten pounds of candy" It also says that Lollipops were 1.6 pounds while tootsie bars were 1.7 pounds. Knowing this I multiplied 1.6 × 10 = 16 for the lollipops. Then I multiplied 1.7 × 10 = 17 for the tootsie bars. Therefore I came to the conclusion that there were 16 bags of lollipops and 17 bags of tootsie bars.
I'm extremely sorry if I am incorrect :(
Answer:
void main(){
string name;
cout<<"Enter Name";
cin>>name;
cout<<"Greetings " ;
cout<<name;
}
Explanation:
in main function we declared a variable called "name" .using cin we are reading the value into name and we are printing that name using cout.
Answer:
The code to this question can be given as:
Code:
int i,j,count_previous=0,count_next=0; //define variable
for (j=0; j<n; j++) //loop for array
{
if (x[0]==x[j]) //check condition
{
count_previous++; //increment value by 1.
}
}
for (i=0; i<n; i++) //loop
{
for (j=0; j<n; j++)
{
if (x[i]==x[j]) //check condition
{
count_next++; //increment value by 1.
}
}
if (count_previous>count_next) //check condition
{
mode=x[i-1];
}
else
{
mode=x[i];
count_previous=count_next; //change value.
count_next= 0 ; //assign value.
}
}
Explanation:
In the question it is define that x is array of the string elements that is already define in the question so the code for perform operation in the array is given above. In the code firstly we define the variable that is i, j, count_previous, count_next. The variable i,j is used in the loop and variable count_previous and count_next we assign value 0 that is used for check the values of array. Then we define the for loop in this loop we use conditional statement in the if block we check that array of zero element is equal to array of j value then the count_previous is increase by 1. Then we use nested loop It is also known as loop in a loop. In this first loop is used for array and the second loop is used for check array element.In this we use the condition that if array x of i value is equal to array x of j then count_next will increment by 1.Then we use another condition that is if count_previous is greater then count_next then mode of x is decrement by 1. else mode equal to array and count_previous holds the value of count_next and count_next is equal to 0.
Answer:
The Java class is given below with appropriate tags for better understanding
Explanation:
public class Cat extends Pet{
private String breed;
public Cat(String name, String owner, String breed){
/* implementation not shown */
super(name, owner);
this.breed = breed;
}
public String getBreed() {
return breed;
}
public void setBreed(String breed) {
this.breed = breed;
}
public String speak(){ /* implementation not shown */
return "Purring…";
}
}
Answer:
Following are the code:
Code:
total = 0; //assign value to total variable.
for (int i=0; i<x.length; i++) //for loop
{
total=total+x[i]; //add all array elements in total variable.
}
Explanation:
In the following question, it is defined that x and total is variable. Where variable x is an integer type array and total is an integer variable. we define some code for calculating the sum of the array element. In the above code, we use for loop that calculates sum of array elements that can be described as:
- To calculate the sum we use the total variable. In total variable, we assign value 0.
- Then we define for loop in loop we use total variables that add all array (x[]) elements.