Answer:
Code is completed below
Explanation:
Source Code in Java:
class Parenthesis
{
boolean hasBalancedParentheses(String eq) //method to check and return if a set of parenthesis is balanced or not
{
int count=0; //to store count of current unclosed opening brackets
for(int i=0;i<eq.length();i++)
{
if(eq.charAt(i)=='(')
count++;
else if(eq.charAt(i)==')')
count--;
if(count<0) //if count falls below zero, there were more closing brackets than opening brackets till this point
return false;
}
if(count>0) //if count is still more than zero, there were less closing brackets than opening brackets
return false;
return true; //if program reaches this point, it has passed all the tests
}
public static void main(String args[])
{
//testing the function
Parenthesis ob=new Parenthesis();
System.out.println(ob.hasBalancedParentheses("()(()())((())())"));
System.out.println(ob.hasBalancedParentheses(")((()())(()))())"));
}
}
Answer:
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
char Keep_Going = '-';
int nextBid = 0;
srand(5);
while (Keep_Going != 'n') { //<-- solution
nextBid = nextBid + (rand()%10 + 1);
cout << "I'll bid $" << nextBid << "!" << endl;
cout << "Continue bidding? ";
cin >> Keep_Going;
}
cout << endl;
return 0;
}
Answer:
I believe its C
Explanation:
I'm sorry if its wrong...
Generally we'd need "the following" if the question asks about it. Senioritis usually affects high school seniors IIRC.
Answer:
//Below are the function which the user needs to add on the place of the "Your solution goes here".
double KelvinToCelsius(double valueKelvin)
{
double valueCelsius;
valueCelsius = valueKelvin - 273.15;
return valueCelsius;
}
Explanation:
Missing information : The above question is missing which states to define one function which name is "KelvinToCelsius" and which takes one argument and changes the kelvin value into Celsius value. One header file syntax is also missing on the above question.
- The above question wants to add a function to the place of the "Your solution goes here" and the work of the function is defined on the question.
- So the above-defined function is used to return the value of Celsius if the user passes the value of kelvin.
- The above-question also holds one function which takes the value of kelvin and returned Celsius, which returns value "283.15".
- So if a user passes "283.15 for the kelvin value, then he got 10 which is defined as Celsius value on the question".