Answer:
answer is below
Explanation:
A left-sentential form is a sentential form that occurs in the leftmost derivation of some sentence. A right-sentential form is a sentential form that occurs in the rightmost derivation of some sentence.
Answer:
Option a is the correct answer for the above question.
Explanation:
- The above question has the option in which two option holds a syntax which is used to declare a variable in PHP language. So the answer is on behalf of the PHP language.
- When a user wants to create an object of any class with the two-parameter in PHP language, then he can do it by the help of "class_name object_name= new class_name($argument1,$argument2)".
- The option 'a' follows the above syntax to create an object of Cart class. Hence it is a correct option while the other is not because:
- Option b states a syntax in which the new keyword is not defined which is used to create a new object.
- Option c states that option in which '$' is not defined to declare a variable.
- Option d states that option in which '$' is not defined to declare a variable.
Answer:
<em>import java.util.Random;</em>
<em>import java.util.Scanner;</em>
<em>public class ANot {</em>
<em> public static void main(String[] args) {</em>
<em> Scanner in = new Scanner(System.in);</em>
<em> Random rand = new Random();</em>
<em> int randomNum = rand.nextInt(100)+1;</em>
<em> System.out.println("ENTER A NUMBER TO PLAY");</em>
<em> int userNum = in.nextInt();</em>
<em> if(userNum<randomNum){</em>
<em> System.out.println("Guess Higher");</em>
<em> }</em>
<em> else if(userNum>randomNum){</em>
<em> System.out.println("Guess Lower");</em>
<em> }</em>
<em> else{</em>
<em> System.out.println("CORRECT GUESS");</em>
<em> }</em>
<em> }</em>
<em>}</em>
Explanation:
- Use the Random class in Java to generate a random number
- Save the random number in a variable
- Use the Scanner Class to prompt user to enter a number as a guess
- Save the user input in a variable
- Use if/elseif/else statements to compare the random number and the number entered by the user.