Compare the following lines of code: 1. What makes these different? (a) If x = 3, what will the first print out? (b) If x = 3, what will the second print out? (c)If x = 1, what will the first print out? (d) If x = 1, what will the second print out?
Q: In a Java Language codes Last month Joe purchased some stock in Acme Software, Inc. Here are the…
A: Java program: //Main class public class Main { //main class public static void…
Q: Can you help me write a pseudocode for the following code The language is Java
A: In computer science and mathematics, the Josephus Problem (or Josephus permutation) is a…
Q: Write a Java programming Language that will accept name of user, three (3) score grades, display the…
A: import java.uti.Scanner; public class PFailed2{ public static void main(String[] args){ Scanner…
Q: This is a java question give me the output with proper explanation max 5 lines explain it not more…
A: Initially b is false and tt is 42 First if is TRUE because tt is less than 50 is true and !b is…
Q: In Java, what is the final keyword? Give a specific example
A: To be determine: Define final keyword
Q: n Java , Write a program on Rock, paper and scissors game
A: **Player.java public interface Player {String[] CHOICES = new String[] { "Rock", "Paper", "Scissors"…
Q: What exactly is an object in java? What is a method in java? What is the difference between an…
A: Actually, java is an Object oriented programming language. It is a platform independent.
Q: If you want to build a system for calculating gasoline consumption in cars, use the Java language to…
A: GasMileage.java public class GasMileage{ double totalMiles, totalGallons; public double…
Q: how to turn the 5 equation into 1 equation in java? how to do it? x = y + 1; y = y - 1; z = z + 1; x…
A: Screenshot of converting 5 given equations into 1 equation:
Q: Given the statement S: "If you are a computer science student, then you know either discrete math or…
A: Answer:
Q: For some reason, my code seems to always output an error in the Java Compiler. I am not sure what's…
A: After declaring class address you have imported the util.Scanner again in the code.
Q: The process of writing Java codes for the computer to perform specific task is called What
A: Actually, computer is a electronic device which takes input and gives the output.
Q: This is using Java only... please do help me.. just an Explanation on the second question.. please…
A: number2/number1 gives you quotient of the division operation number2/number1 gives you remainder of…
Q: 2. What is Mutator? a. Explain using a proper java programming example and its output. PS: Please…
A: Java is the object oriented programming languages. It is designed that it contains the high level,…
Q: for this java program i am suppose to do the figure on the top left and put it in rows and columns…
A: Note: Modified Code highlighted in bold. Code: import java. awt.*; public class DrawingTest {…
Q: Write a java program to take the number from the user and prints you look older than
A: import java.util.Scanner; publicclassNumOld { public static void main(String[] args) //…
Q: Java program: Your job is to write a program that does the following: Prompts the user to enter…
A: According to the question below the Solution: Output:
Q: Describe how you would create a Java program that prompted the user to correctly enter a username…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a java program by taking two variables num1 and num2 with values of your own and perform the…
A: Please find the answer below :
Q: Write a java program that outputs and prints the number of hours, minutes, and seconds that…
A: public class Main { private static int SECONDS_PER_HOUR = 3600; private…
Q: Write a Java programming language that will accept two (2) numbers and determine the large and small…
A: package prassu;import java.util.Scanner;public class A {public static void main(String args[]){int…
Q: (Display three messages) Write a program that displays Welcome to Java,Learning Java Now, and…
A: Program code: //define class DisplayMessages class DisplayMessages { //define main method…
Q: What is the value of the postfix expression 6 8 4 2 + – *?(java) a. 8 b. 12 c. -12 d. 10
A: What is the value of the postfix expression 6 8 4 2 + – *?(java) a. 8 b. 12 c. -12 d. 10 Answer:…
Q: If the following statement were used in a Java program, it would cause something to be written to…
A: The given section of code is a snip of java programming. The first statement is a…
Q: How do you write this pseudocode into Java
A: m and n are normal integers which stores lengths of X and Y b and c are two dimensions arrays with…
Q: Write a program that displays Welcome to Java, Welcome to Computer Science, and Programming is fun.
A: Since you are not mentioning the programming language, here we are using Java to complete the…
Q: Write a program to read Radius and calculate the area and perimeter of the circle in JAVA
A: import java.util.Scanner; class Main { public static void main(String args[]) {…
Q: Write a Java program to compare the populations of two states. (1) Ask the user to input the name…
A: import java.util.Scanner;class population { public static void main(String[] args) { //…
Q: Write a java program to print the flag of America.
A: To Do: To write code in java.
Q: Write a Java program for a Play-House Manager, who would like to calculate the total profit from…
A: The JAVA code is given below with code and output screenshot
Q: The problem states that there are five philosophers sitting around a circular table. The…
A: Problem statement: The problem states that there are five philosophers sitting around a circular…
Q: How to count the number of digits in a number in java?
A: The below given Java program will obey the following rubrics: Including the required data package.…
Q: Write a Java program that prompts the user to enter their weight in Kilograms and then convert it in…
A: Algorithm: 1. Read weight in Kilograms as weightKg. 2. Convert into Pounds as weightPounds =…
Q: Write a Java program that asks a user to enter three numbers and print out the least one
A: According to the question below the solution: in question mention print least one so i print the…
Q: Java Programming Create a program that computes the perimeter of a square, rectangle and the…
A: Here I have created an interface named Shape and inside the interface, I have declared a method to…
Q: First code is top, second code is on bottom. This is for Java.
A: Step 1 : create two java class Step 2 : write down first in one java class and second code in second…
Q: Prompt the user for a number x and output the sum of all numbers from 1 to x. If the number entered…
A: Algorithm: Start Read a number n If n==0, print "Hey, I said positive" Else if n<0, print "Hey,…
Q: In Java 1-make a program that prompt the user enter a shape name (Circle or Rectangle or line ) and…
A: The complete code is given below with output.
Q: with a java programme Last month Joe purchased some stock in Acme Software, Inc. Here are the…
A: Details of purchase: The number of shares that Joe purchased was 1,000. When Joe purchased the…
Q: Give a statement or statements that can be used in a Java program to write the following to the…
A: Statements in java language to print two statements on screen.
Q: What is the output of this Java program?
A: 74 will be printed
Q: In Java program, please show the output of the program.
A: import java.util.Scanner;public class ThreadProgram implements Runnable{ public static void…
Q: 1) What is difference between wait() and sleep() method?
A: Given:
For Java
Compare the following lines of code:
1. What makes these different?
(a) If x = 3, what will the first print out?
(b) If x = 3, what will the second print out?
(c)If x = 1, what will the first print out?
(d) If x = 1, what will the second print out?
Step by step
Solved in 2 steps
- In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.Create a simple illness Check-up Java program. This program must implement encapsulation and polymorphism. Example: System: Good day. What can we do for you? User: I am sick. System: These are the available services Pediatric Pulmonary Internal Medicine Simple consultation The program must implement encapsulation and polymorphism.import java.util.*; public class CardGame { static Scanner scanner = new Scanner(System.in); static Random random = new Random(); public static void main(String[] args) { System.out.println("Welcome to the card game! Here are the instructions:"); System.out.println("- You will randomly draw a card from a deck of 52 cards."); System.out.println("- The computer will also draw a card from the same deck."); System.out.println("- If your card has a higher face value, you win. Otherwise, you lose."); System.out.println("- If your card has the same face value as the computer's card, the suit determines the order."); int gamesPlayed = 0; int userWins = 0; int computerWins = 0; boolean[] cards = new boolean[52]; // false means the card is available, true means it's been drawn while (true) { System.out.println("\nNew game!"); int[] userCard = drawCard(cards); int[]…
- In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Set the length of the rectangle to 24 and the width to 30.Explain this java codes private void put(int cell,int player) { int i=-1,j=-1;; switch(cell) { case 1:i=2;j=0;break; case 2:i=2;j=1;break; case 3:i=2;j=2;break; case 4:i=1;j=0;break; case 5:i=1;j=1;break; case 6:i=1;j=2;break; case 7:i=0;j=0;break; case 8:i=0;j=1;break; case 9:i=0;j=2;break; default:display(overridegrid);return; } char mark='x'; if(player==0) mark='o'; grid[i][j]=mark; display(grid); } private int startGame() { init(); display(grid); int status=playingid; while(status==playingid) { put(playerMove(),0); if(override==1) { System.out.println("O wins."); return playerid; } status=checkForWin(); if(status!=playingid) break; try{Thread.sleep(1000);}catch(Exception e){System.out.print(e.getMessage());} put(compMove(),1); status=checkForWin(); } return status; } private void init() { movesPlayer=""; override=0; marks=new int[8][6]; wins=new int[][] //new int[8][3]; weights=new int[]{3,2,3,2,4,2,3,2,3}; grid=new…Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - Given the following code, the output is __. class Sample{ public static void main (String[] args){ try{ System.out.println(5/0);}catch(ArithmeticException e){ System.out.print("Divide by zero????");}finally{ System.out.println("5/0"); } }} A. Divide by zero????B. 5/0C. Divide by zero????5/0D. 5/0Divide by zero????E. "5/0" Part 2 - Given the following code, the output is __. try{ Integer number = new Integer("1"); System.out.println("An Integer instance.");}catch (Exception e){ System.out.println("An Exception.");} A. An Integer instance.B. An Exception.C. 1D. Error: ExceptionE. None of the options
- # Coding - Simulate a robot Write a program that simulates the movements of a robot. The robot can have three possible movements: turn right turn left advance The robot is placed on a hypothetical infinite grid, facing a particular direction (north, east, south, or west) at a set of `{x,y}` coordinates,e.g., `{3,8}`, with coordinates increasing to the north and east. Create a Class `Robot` that contains a method `execute` which given a number of instructions will calculate the robot's new position, and the the direction in which it is pointing. ## Example The letter-string "RAALAL" means: Turn right Advance twice Turn left Advance once Turn left yet again Say a robot starts at `{7, 3}` facing north. Running this stream of instructions should leave it at `{9, 4}` facing west. ## Inputs and Outputs The argument of the `execute` is `string` in the format `X Y BEARING COMMANDS`. The method should return a one-liner `string` in the format `X Y BEARING`. In the…In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Declare an instance of rectangleType.public class TestAverage {public static void main(String[] args) {int test1, test2, test3, sum;Scanner reader = new Scanner(System.in);System.out.println("Enter test 1");test1 = reader.nextInt();System.out.println("Enter test 2");test2 = reader.nextInt();System.out.println("Enter test 3");test3 = reader.nextInt();sum = test1 + test2 + test3;System.out.println("The sum is " + sum);System.out.println("The average is " + sum / 3);}}There is one logic error in this code explain what is wrong and how to fix it.
- Write java program for the following class diagram . The Instructions: 1. This java program is for an application that stores the author (Writer) data of some books and emails. 2. getAuthors() method get the list of authors and store it in a String array. 3. addAuthors() method is used to add an author anytime for book or email. 4. getDate() method get the date of the book or email. 5. getTitle() method can be used to get the title of the book. 6. getSubject() method is used to get the Subject of the email. 7. getTo() method is used to get the information about the mail to whom it is sent. 8. All get methods need to return the values in the corresponding instance variables. 9. Scanner class can be used to set the data for the variables. The programmer can give his/her own methods to set the instance variables.It is convention that all metmber variables in a Java class are declared to have_____ access so they are not accessible outside the class.Please help me solve this with java .... just the HangMan HangMan instruction class : • HangMan is a game in which a player tries to guess a word based on a given hint. For example, if the given hint is “movie”, then the player must guess a movie name. If the given hint is a “country”, then the player must guess a country name, and so on.• The game starts by showing a message on the screen that shows the hint and all letters in the word but obscured as dashes (-). Then, the game will allow the player to guess 5 letters. If the player gives a letter that actually exists in the word, then this letter will be revealed. Afterwards, the game will ask the player to give the answer. If the given answer is correct, then the game will show a message that the player has won 5 points. Otherwise, the game will show a message that the player has lost. Below is one possible game scenario, in which the word is “iron man”, and the hint is “movie”. Note that the text in green color is the…