Answer:
public class Car {
private String __year_model;
private String __make;
private int __speed;
//Creating the constructor
public Car(String __year_model, String __make, int __speed) {
this.__year_model = __year_model;
this.__make = __make;
this.__speed = __speed;
}
//Creatining the set and get methods
public String get__year_model() {
return __year_model;
}
public void set__year_model(String __year_model) {
this.__year_model = __year_model;
}
public String get__make() {
return __make;
}
public void set__make(String __make) {
this.__make = __make;
}
public int get__speed() {
return __speed;
}
public void set__speed(int __speed) {
this.__speed = __speed;
}
}
Explanation:
As stated in the question, The class Car is created using Java programming language with the three attributes year_model, make and speed.
Constructors as well as set and get methods were also created for each of the fields.
Answer:
they send electrical signals to the buzzer. The buzzer changes those electrical signals into sound. You hear the buzzer sound and know that someone is calling you.
Explanation:
Answer:
static int checkSymbol(char ch)
{
switch (ch)
{
case '+':
case '-':
return 1;
case '*':
case '/':
return 2;
case '^':
return 3;
}
return -1;
}
static String convertInfixToPostfix(String expression)
{
String calculation = new String("");
Stack<Character> operands = new Stack<>();
Stack<Character> operators = new Stack<>();
for (int i = 0; i<expression.length(); ++i)
{
char c = expression.charAt(i);
if (Character.isLetterOrDigit(c))
operands.push(c);
else if (c == '(')
operators.push(c);
else if (c == ')')
{
while (!operators.isEmpty() && operators.peek() != '(')
operands.push(operators.pop());
if (!operators.isEmpty() && operators.peek() != '(')
return NULL;
else
operators.pop();
}
else
{
while (!operators.isEmpty() && checkSymbol(c) <= checkSymbol(operators.peek()))
operands.push(operators.pop());
operators.push(c);
}
}
while (!operators.isEmpty())
operands.push(operators.pop());
while (!operands.isEmpty())
calculation+=operands.pop();
calculation=calculation.reverse();
return calculation;
}
Explanation:
- Create the checkSymbol function to see what symbol is being passed to the stack.
- Create the convertInfixToPostfix function that keeps track of the operands and the operators stack.
- Use conditional statements to check whether the character being passed is a letter, digit, symbol or a bracket.
- While the operators is not empty, keep pushing the character to the operators stack.
- At last reverse and return the calculation which has all the results.