THIS IS MEANT TO BE WRITTEN IN JAVA. The assignment is to get an integer from input, and output that integer squared, ending with newline.
Q: Write a Java program that prompts the user to enter a grade for a student. The program displays…
A: Program import java.util.Scanner; public class Main{ public static void main(String args[]) {…
Q: Write a program that prompts a student to enter a Java score. If thescore is greater or equal to 60,…
A: Program: //import the header file import java.util.Scanner; //definition of class public class…
Q: Finish the Java program inputNewPlayerLocation: to input (x,y) coordinates from user (using…
A: Point is the built-in java class that is available to use in java.awt package The Point class…
Q: ODY OF Java program - THE checkWinner METHOD BELOW SO THAT THE GAME STOPS WHEN SOMEONE WINS, OR WHEN…
A: Please note as per the given displayRow(): void dispRow(int r) { System.out.println(board[r][0] +…
Q: In this exercise, you are going to complete the Rectangle class. You need to complete the class so…
A: Java code is as follows:-
Q: Use Java program to add a method printReceipt to the CashRegister class. Then create a driver class…
A: The two additional methods are to be added to the CashRegister class. The methods are addItem and…
Q: Write a Java program that takes an integer as input and computes and displays the reverse of that…
A: Let us see the answer (introduction) : Loop : A loop is a set of instructions that are repeatedly…
Q: program segment at the locations of // #### your code here ... to acquire the input from the user…
A: First create scanner object and then call required methods.
Q: I need help to Fill in the two methods in the .java file in the following below:
A: sum function adds up elements of two arrays at same index and returns the new array cutOffTheCrust…
Q: Can anyone help me with a java program that'll write a boolean method, called isOnOrAfter, which…
A: Program import java.util.*;public class Main { public static void main(String[] args) {…
Q: Use Java program to add a method printReceipt to the CashRegister class. The method should ask the…
A: Use two arrays one to store names and other to store prices
Q: use java Implement a class Car with the following properties. A car has a certain fuel efficiency…
A: public class Main{public static void main(String[] args) { Car c = new Car(50);…
Q: There is a problem with my program. I need the JOptionpane to pop up when I run the program and…
A: The ask is to debug the program and fix the JOptionPane issue.
Q: Write a complete Java program that prints out the following information: Ask the user to enter the…
A: The main objective of the java program, Rabab.java is to prompt the user to enter the last three…
Q: Write a Java program that prints a special triangle containing both numbers and letters as mentioned…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: debug my program? it's in Java. At line 108, I get the error “The field Person.age is not visible”.…
A: Error found while executing your program: - Explanation: - After executing the given program the…
Q: Below was the java code that i was hald done on it. in the java code, it supposed to count on min…
A: File name: “draft.java” import java.util.Scanner; public class draft { public static void…
Q: Write in Java: Given main(), complete the Car class (in file Car.java) with methods to set and get…
A: public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int…
Q: I need to do this in python, help. 7- create a class that represents a point on the Cartesian…
A: Python program to create two classes point and triangle that do the required function mentioned in…
Q: Write a java class that corrects a sentence. Your class must capitalize the letter in each…
A: Steps in program: Take string as input Create new string same as input string using String Buffer…
Q: THIS IS MEANT TO BE IN JAVA So far we've learned variables, branches, loops, and some array. The…
A: Here I have taken input from the user and stored it into a variable. Next, I have checked for the…
Q: JAVA
A: Given a long integer representing a 10-digit phone number, output the area code, prefix, and line…
Q: Using Jcreator, open, compile, and run java and observe its runtime. Write your observation…
A: First let's understand what is encapsulation and then try to obersve the code Encapsulation :-…
Q: Write up Java source codes for compiling and execution of program below. There is a very simple…
A: The code is an given below :
Q: Write a Java program that has a class named TEST2 which contain the method named SUM1 to find the…
A: Here I have created a function named SUM1(). This function iterates over the list of numbers and…
Q: Write a Console Java program without using package names, that asks the user to enter one sentence…
A: Introduction of Program Java, object-oriented computer programming language. Java was created at Sun…
Q: Take a string and a word from user and check whether this word is present in that string or not.…
A: Required:- Take a string and a word from the user and check whether this word is present in that…
Q: Write a Java program which allow user to enter a number that represents repetition. Then, the user…
A: In this question, we are writing a java program which calculate the average of numbers and count how…
Q: This is the question - Use the web to learn how to use the LocalDate Boolean methods isBefore(),…
A: Use the web to learn how to use the LocalDate Boolean methods isBefore(), isAfter(), and equals().…
Q: I need help adding a new line at the end of the output string here is my Java code, and it is all…
A: There are two ways to put a new line after the output is printed in the given code. Given JAVA code:…
Q: Someone please help me . Based on the java code given, how can i improve the error (photo1) and add…
A: Inheritance in Java Definition: Inheritance is a concept that attains the properties from one class…
Q: Write a Java program that will ask for a string of letters . Each letter in the alphabet is given…
A: Objective: This program reads a string and displays it in the reverse order using the given code.…
Q: write a code for costumercheckout.java and test file. give explanation "implement the observers for…
A: Start Customer required items Scan the items customer want Calculate the price to checkout After…
Q: Write a java program, This program should play a game of dice: you against the computer... (well,…
A: Game playing with two dies And one die roll by the Computer and another one is rolled by the game…
Q: Write a Java program called ThreeWords that prompts (asks) the user to enter three words, separated…
A: import java.util.Scanner;class ThreeWords { public static void main(String args[]) { Scanner sc =…
Q: Write a Java method named check() that checks the validity of a password received as string…
A: Algorithm : check function : Step 1 : declare variables. Step 2 : initialize variables. Step 3 :…
Q: will output the weekday string (which is Thursday) on the console for March 14, 2019).
A: solution is given below in code snippet
Q: We had given two strings r and s and check
A: Q: We had given two strings r and s and check whether r can be formed from s return true and false…
Q: How can you add a new line at the the end of of the output string in Java. The output is correct but…
A: import java.util.Scanner; public class Main//LabProgram { //method drivingCost definition…
Q: I Need to write a program based on the following Java program PercolationEstimation.java that uses…
A: PercolationEstimation.java:- Solution is given below:-
Q: Write a java Program that implements a calculator and it should have the 6 basic Operatoin :…
A: Java code :- import java.awt.event.*; import javax.swing.*; import java.awt.*; class calculator…
Q: Write a java program which will input an integer value from the user (Use Scanner class). Your…
A: Here I have created the function mathOper(). In this function, I have modified the value of a,b, and…
Q: HIS IS MEANT TO BE IN JAVA So far we've learned variables, branches, loops, and some array. The…
A: The given problem is related to programming where the program is to be implemented in Java language.…
Q: Write a line of Java code that will give the name ANSWER to the int value 42.In other words, make…
A: - The question wants to know how to initialise a named constant ANSWER with an integer value 42 in…
Q: X is a Elenment in java (maybe?) x1 is a value of T and x2 is a set of T and k(k is a local…
A: Actually, given information X is a Element in java (maybe?) x1 is a value of T and x2 is a set of T…
Q: Below is the code in Java to add 2 binary Numbers: Both the codes execute, Could someone explain…
A: In digital electronics and mathematics, a binary number is a number expressed in the base-2 numeral…
Q: For this assignment, write a program called Payday.java that will compute and print a person's…
A: Required: For this assignment, write a program called Payday.java that will compute and print a…
Q: Write a java class that corrects a sentence. Your class must capitalize the letter in each…
A: The program is written in Java. Please find the source code and output in the following steps.
Q: Use your imagination to come up with a situation where you can write a program that contains two…
A: break statement is useful in exiting the loop before reaching the last iteration For example, you…
THIS IS MEANT TO BE WRITTEN IN JAVA.
The assignment is to get an integer from input, and output that integer squared, ending with newline.
Where i'm doing my assignment, in a seperate part of the assignment outside of the code, there's an option that says, "Enter
This is what I have so far and it doesn't run...
import java.util.Scanner;
public class NumSquared {
public static void main(String[] args) {
//main() method
Scanner scnr = new Scanner(System.in);
//declaring variable to store user input
int userNum;
//declaring variable to store square of a number
int userNumSquared;
//reading number
userNum = scnr.nextInt();
//multiplying number to it self to find square
userNumSquared = userNum *userNum;
//print square of a number
System.out.print(userNumSquared);
}
Please explain why it's not running and please show the completed code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- THIS IS MEANT TO BE IN JAVA So far we've learned variables, branches, loops, and some array. The assignment is: Given a long integer representing a 10-digit phone number, output the area code, prefix, and line number using the format (800) 555-1212. Ex: If the input is: 8005551212 the output is: (800) 555-1212 We were given these hints which I don't see how they would help: Hint: Use % to get the desired rightmost digits. Ex: The rightmost 2 digits of 572 is gotten by 572 % 100, which is 72. Hint: Use / to shift right by the desired amount. Ex: Shifting 572 right by 2 digits is done by 572 / 100, which yields 5. (Recall integer division discards the fraction). For simplicity, assume any part starts with a non-zero digit. So 0119998888 is not allowed. Please show the end result and explain why you added what you added. This is all I have so far: import java.util.Scanner; public class LabProgram {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);long…IN JAVA - Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer. End with a newline. Ex: If the input is: -15 10 the output is: -15 -10 -5 0 5 10 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. For coding simplicity, output a space after every integer, including the last. BASE CODE: import java.util.Scanner; public class LabProgram { public static void main(String[] args) { /* Type your code here. */ }}Write a java program and also attach SS of output. Why do we need encapsulation? What happens if data is not encapsulated within a class? Is there a way to access data which is encapsulated in a class? Give examples to encapsulate data within class and package. There is an online banking system where a user can view his contact info, account summary, add few beneficiaries account details. The bank officer can also view user's contact info, account summary, ATM card charges, bank charges, and other deductions. Create a class Customer and define its attributes and method names with proper access modifiers i.e. public, private or default.
- I need help adding a new line at the end of the output string here is my Java code, and it is all correct except at the end of the output it is requiring a newline after. import java.util.Scanner; public class LabProgram { //method drivingCost definition public static double drivingCost(double drivenMiles,double milesPerGallon,double dollarsPerGallon){ double yourValue; yourValue = (drivenMiles/milesPerGallon)*dollarsPerGallon; System.out.printf("%.2f ", yourValue); return yourValue;} public static void main(String[] args) { double milesPerGallon; double dollarsPerGallon; Scanner sc = new Scanner(System.in); milesPerGallon = sc.nextDouble(); dollarsPerGallon = sc.nextDouble(); drivingCost(10, milesPerGallon, dollarsPerGallon); drivingCost(50, milesPerGallon, dollarsPerGallon); drivingCost(400, milesPerGallon, dollarsPerGallon); }}I have a difficult task that i have been given, the problem is that I just simply cant seem to manage to first print a binary number so if you give me six my code doesnt seem to print the number in binary. but also i need to print it in reverse and my code just doesnt seem to work with that. heres my code import java.util.Scanner; public class LabProgram { public static void main(String[] args) { int x; int output; int i; Scanner input = new Scanner(System.in); x = input.nextInt(); output = x; for ( i = 0; i <= x; i = ++i){ output = x / 2; System.out.println(output); } } } // and bellow this are my instructions . what am i doing wrong what am i missing? ive googled sites and erased portions of code, put in eithers. ive switched back and forth from a for loop to a while loop for awhile now Write a program that takes in a positive integer as input, and…WRITE THE BODY OF Java program - THE checkWinner METHOD BELOW SO THAT THE GAME STOPS WHEN SOMEONE WINS, OR WHEN THE BOARD IS FULL. AS SHOWN IN THE SAMPLE OUTPUT AT THE BOTTOM. Code: import java.util.Scanner; public class TicTacBoard { private char[][] board; // 2-D array of characters private char curPlayer; // the player whose turn it is (X or O) // Constructor: board will be size x size public TicTacBoard(int size) { board = new char[size][size]; // initialize the board with all spaces: for(int row=0; row < board.length; row++) for(int col=0; col < board[row].length; col++) board[row][col] = ' '; curPlayer = 'X'; // X gets the first move } public void playGame() { display(); do { takeTurn(); display(); }while(!checkWinner()); } /////// display //////// // Display the current status of the board on the // screen, using hyphens (-) for horizontal lines // and pipes (|) for vertical lines. public void…
- Write a java class that corrects a sentence. Your class must capitalize the letter in each sentence. Make sure that after each [.], [!] , [?] will the word after it will be capitalized. for example : Input : i love myself! yes. no , really? maybe Output: I love myself! Yes. No ,really ? Maybe For example: Input Result after a train crashed, every single person died. who survived?all of the couples. After a train crashed, every single person died. Who survived?All of the couples. turn us on our backs and open up our stomachs, and you will be the wisest but at the start a lummox. what are we? books. Turn us on our backs and open up our stomachs, and you will be the wisest but at the start a lummox. What are we? Books. help! help! it's an emergency. Help! Help! It's an emergency.Write a java program that simulates a game of dice. In this game, 3 players will take alternateturns rolling two dice. On each turn, they record the sum of the two dice and add this totheir total. If a player rolls a doublet (both dice have the same value), then the player getsto roll again until the doublet disappears. After each turn (when both roll), the code checks the sum of each player and the firstplayer to reach a total of 15 or more will win the first place. When a player surpasses 15but with a doublet (both dice have the same value), the player still gets to roll again untilthe doublet disappears. The code then checks for the second and third place winners. Thecode will print out to the user the winners in order. If 2 or all the players hit the same sum, you can consider them all first place winners (forexample, if player 1 and 2 hit the same sum that’s >= 15 and 3rd player hits a sum lessthan 15, then you can say 1st and 2nd players win first place and 3rd wins second…Use Java program to add a method printReceipt to the CashRegister class. Then create a driver class that asks the user to input the 5 items that they have bought recently and also the prices for each item, and print the items, their prices, and the total amount due. Hint: You will need to form a string of all prices. Use the concat method of the String class to add additional items to that string. To turn a price into a string, use the call String.valueOf(price). Also, the payment information will need to be the same as the price information. Here is the CashRegister class: /** A cash register totals up sales and computes change due.*/public class CashRegister{ private double purchase; private double payment; /** Constructs a cash register with no money in it. */ public CashRegister() { purchase = 0; payment = 0; } /** Records the sale of an item. @param amount the price of the item */ public void recordPurchase(double amount) {…
- can you solve this please? Adopt appropriate Java animation code to implement the video in the file “test4.wmv” and given that the parametric equation for a circle. x=r*cos(t) y=r*sin(t) with t in range [0, 2p] and r is the radius of the circle. (the circle goes in a loop like in the images, i did my best to try to explain it , please try to do it ) and here is a sample of what they want me to use : package javaapplication1;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.awt.geom.*;import java.util.Random;import javax.imageio.*;import java.io.File;import java.io.IOException;import java.awt.image.BufferedImage;import java.awt.event.*;import java.util.Calendar; public class JavaApplication1 extends JApplet { public static void main(String[] args) { JFrame frame=new JFrame(); frame.setTitle("hello"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applete =new JavaApplication1(); applete.init();…Write a JAVA program that checks phrases to determine if they are palindromes. A palindrome is a word, phrase, or sentence that reads left-to-right the same way it reads right-to-left, ignoring all punctuation and capitalization. For example, the statement “Madam, I’m Adam” is a palindrome as the response of “Eve.” Use a method to determine if a String is a palindrome. Test a single word non-palindrome, a single word palindrome, a phrase that is not a palindrome, and a phrase that is a palindrome. Print the phrase and whether it is a palindrome or not. Some simple palindromes are “racecar,” “taco cat,” and “A man, a plan, a canal, Panama!” There are a few different approaches for the test; choose one of your liking. Hint: extract all letters, change the remaining letters to lowercase, then test if the phrase is a palindrome.Write a java program, This program should play a game of dice: you against the computer... (well, actually it's computer vs computer, but the first computer rolls for you), You are given a method roll() that returns a random integer between 1 and 6 Use it to play a game: - first "you" roll two dice and report the outcome, - then the computer rolls two dice and reports. - Finally, the program compares two sums and declares the winner. - In case of a tie, you win (not fair for the computer, but life's not fair) The output should look similar to this: ======== You roll 6 and 6. Sum = 12 Computer rolls 1 and 4. Sum = 5 12 is greater than or equal to 5. You win :( ======== or ======== You roll 3 and 6. Sum = 9 Computer rolls 6 and 4. Sum = 10 9 is less than 10. Computer wins!!! ======== Implement the unfinished steps indicated by ...