GSU Java Programming Language Questions
Description
Unformatted Attachment Preview
1. public class CountDigits {
2.
public static void main(String[] args) {
3.
SimpleIO.prompt(“Enter an integer: “);
4.
String userInput = SimpleIO.readLine();
5.
int number = Integer.parseInt(userInput);
6.
int numDigits = 0;
7.
while (number > 0) {
8.
number /= 10;
9.
numDigits++;
10.
}
11.
System.out.println(“The number ” +
userInput + ” has ” +
numDigits + ” digits”);
12. }
13. }
any contemporary languages allow two kinds of comments: one in which
delimiters are used on both ends (multiple-line comments), and one in which
a delimiter marks only the beginning of the comment (one-line comments).iscuss the advantages and disadvantages of each of these with respect to the
main four evaluation criteria of programming languages.
The following class contains several errors that violate the rules of Java:
1. class Thermometer {
2.
private int temperature
3.
public Thermometer(int degrees) {
4.
temperature = degrees;
5.
}
6.
public Thermometer() {
7.
temperature = 0.0;
8.
}
9.
public void makeWarmer(int degrees) {
10.
temperature =+ degrees;
11. }
12. public void makeCooler(int degrees) {
13.
temperature -= degrees;
14. }
15. public getTemperature() {
16.
return temperature;
17. }
18. public string tostring() {
19.
return temperature + $egrees’;
20. }
21. }
Describe each error and specify whether it is (a) lexical, (b) syntactic, or (c)
semantic. Use the numbers shown to identify the line on which each error
occurs.
Purchase answer to see full
attachment
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."