import java.util.Scanner; public class TriangleArea { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Triangle triangle1 new Triangle(); Triangle triangle2 = new Triangle();
Q: Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with…
A: import java.util.*; public class TeenagerDetector {public static void main (String [] args) {Scanner…
Q: Find error and correct it : public class ProgramLayout { public static void main (String[]…
A: We are going to predict the error in the following code.
Q: Summary In this lab, you complete a partially prewritten Java program that includes methods with no…
A: Here I have taken input from the user and then stored it into a variable of string type. Next, I…
Q: What is printed by the code below? Note: There are two separate classes here. public class…
A: Answer : the given code is in java here I Provide a typed code as well as the output of the code…
Q: public class ArrayMerge { static void arrayMerge(int a[], int b[]){ int c[] = new…
A: Please find the solution below
Q: Given the IntNode class, define the findMax() method in the Custom Linked List class that returns…
A: We have a CustomLinkedList class and an IntNode class in the Java code that has been provided. The…
Q: public class Test { public static void main(String[] args) { int arr[] = {1,2,3,4,5}; int count = 0;…
A: The program is to double the even elements in an array.
Q: Define a method findMenuCost() that takes two integer parameters as the menu chosen and the number…
A: We must complete the Java program to find the cost per person per the given inputs.There are two…
Q: Compute: z = (x + y)° Ex: If the input is 4.0 2.0, then the output is: 216.0 1 import…
A: Here we have to apply formula for (a+b)3 = a3 + b3 + 3a2b + 3ab2, Let's apply this in program.…
Q: import java.util.Scanner;
A: Given :- In the above question, a code fragment is mention in the above given question Need to…
Q: import java.util.Scanner; public class LabProgram { public static void main(String[] args) {…
A: there are multiple syntax errors in your code. The following corrections are to be made.Removed…
Q: Complete main() to read dates from input, one date per line. Each date's format must be as follows:…
A: Algorithm: DateParser1. Define a function getMonthAsInt(monthString) that takes a month string as…
Q: This isn't not working for me. import java.util.Scanner; public class LabProgram { public…
A: The error is due to a typo in the code. The variable in is not declared and the correct variable is…
Q: Write a program that reads a list of integers, and outputs whether the list contains all multiples…
A: For the given scenario, the first element of the array is to be ignored while making a decision. So,…
Q: What will the given code prints on the output screen.
A: Given, Programming language = JAVA Code: class isNaN_output { public static void main(String…
Q: Write an if-else statement for the following: If userTickets is less than 6, execute award Points =…
A: Your given program is logically correct but the issue is in the closing of blocks. Blocks were…
Q: import java.util.Scanner; public class Relational { public static void main(String [ args) { int…
A: Given To complete the java program. import java.util.Scanner; public class EqualityAndRelational…
Q: The while loop reads values from input until an integer is read. Complete the exception handler in…
A: This program will repeatedly prompt the user for input for input till a legitimate integer is…
Q: How do I mahe my code output results Java? Code: import java.util.Scanner; class FinalExamAnswer…
A: The Answer is
Q: public class MathF{ public static void main(String[] args) { char[] grade=new char[4]; grade[1]='B';…
A: Provided the output of the above code in the next step with a screenshot.
Q: class MyAbstract { public int doNothing() { System.out.print("abc"); } return 1;
A: In step 2, I have provided ANSWER WITH BRIEF EXPLANATION----------- In step 3, I have provided…
Q: change to ada language import java.util.scanner; public class problem41 { public static void…
A: Program in Java: #include <stdio.h> int main() { int positives = 0; // Count the…
Q: import java.awt.*; public class TestRandomWalker { public static final int STEPS = 500; public…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: import java.util.*; public class Main{ public static void main(String[] args) {…
A: The solution to the given problem is below.
Q: } } import java.util.*; public class Problem$16 { public static void main(String[] args) { Scanner…
A: Step-1: StartStep-2: Declare variable side and take input from the user Step-3: Declare variable…
Q: import java.util.Scanner; public class DebugSix3 { public static final int TIME_WASTER = 500;…
A: Import the Scanner class.Define the constant TIME_WASTER with a fee of 500.Define the primary…
Q: Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints…
A: Program: import java.util.Scanner; public class StudentScores { public static void main (String…
Q: package go; package demo; public class Pokemon { import L; // import Pokemon class (#1) private int…
A: Please refer to the following step for the complete solution of the problem above.
Q: Not all tests passed. X 1: Compare output ^ Output differs. See highlights below. Input 100 Annual…
A: I modified the code and provide the code with the correct output and code screenshot and code…
Q: Fix all logic and syntax errors. Results Circle statistics area is 498.75924968391547 diameter is…
A: // Some circle statistics public class DebugFour2 { public static void main(String args[]) {…
Q: Write a class that keeps track of concert promotion information. First download ConcertPromoter.java…
A: answer starts from step 2
Q: I have my code here and I am getting errors (I have also attached my code): " import…
A: Initializе a list of scorеs and a scorе count variablе.Whilе thе scorе count is lеss than thе…
Q: public class Qla { Run | Debug public static void main (String [] args) { int n = 1000; int mySum 0;…
A: public class Q1b { publicstaticvoidmain(String[] args) { floatsum = 0; intx = 0; floatcount = 0;…
Q: import java.util.Scanner; public class AverageWithSentinel { public static final int…
A: Algorithm: Start Initialize count and total to 0 Read a number n If n!=-500, increment count by 1…
Q: import javax.swing.JOptionPane; public class DebugTwo4 { // start main method public static void…
A: import javax.swing.JOptionPane; public class DebugTwo4 { // start main method public static void…
Q: 1. Modify your program from 04 Hands-on Activity 1 to apply encapsulation. Make bloodType and…
A: Encapsulation is an object oriented feature where data is wrapped together and access provided using…
Q: public class Main { public static void main(String args[]) { Main m = new Main();…
A: Here is the step by step instructions Make sure that all the files are in the same folder and…
Q: import javax.swing.JOptionPane; public class Mileage { public static void main(String[] args)…
A: The String class of java.lang package is the default package that is imported by every java program.…
Q: import java.util.Scanner; public class ParkingFinder { /* Your code goes here */ public…
A: In this question we have to write a java program for the Daily Parking Price System Let's code and…
Q: Output is nearly correct, but whitespace differs. See highlights below. Special character legend…
A: Below is the complete solution with explanation in detail for the given question about the…
Q: public class main { public static void main(String [] args) { Dog dog1=new…
A: Program: public class main { public static void main(String [] args) { Dog dog1=new…
Q: public class Ex08FanTest { public static void main (String[] args){ Ex08Fan fan1= new…
A: package Ch9; /** * ************** Fan ************** * * +SLOW: int * +MEDIUM: int * +FAST: int *…
Q: Given string inputStr on one line and integers idx1 and idx2 on a second line, output "Match found"…
A: Your java program is given below as you required with an output. Algorithm : The code reads in the…
Q: import java.util.Scanner; public class CircleAndSphereWhileLoop { public static final double…
A: import java.util.Scanner; public class VolumeOfSphereUsingMethod { private static Scanner sc;…
Q: PART 2: Variables, Constants, and Arithmetic The following are sample runs of the program to help…
A: Program description: Java program, StringFun.java that prompts the user to enter the first name and…
Step by step
Solved in 4 steps with 5 images
- import java.util.Scanner; public class Inventory { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); InventoryNode headNode; InventoryNode currNode; InventoryNode lastNode; String item; int numberOfItems; int i; // Front of nodes list headNode = new InventoryNode(); lastNode = headNode; int input = scnr.nextInt(); for(i = 0; i < input; i++ ) { item = scnr.next(); numberOfItems = scnr.nextInt(); currNode = new InventoryNode(item, numberOfItems); currNode.insertAtFront(headNode, currNode); lastNode = currNode; } // Print linked list currNode = headNode.getNext(); while (currNode != null) { currNode.printNodeData(); currNode…import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print(" "); String s1 = sc.nextLine(); System.out.print(""); String s2 = sc.nextLine(); int minLen = Math.min(s1.length(), s2.length()); int matchCount = 0; for (int i = 0; i < minLen; i++) { if (s1.charAt(i) == s2.charAt(i)) { matchCount++; } } if (matchCount == 1) { System.out.println("1 character matches"); } else { System.out.println(matchCount + " characters match"); } sc.close(); }}8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). - Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: Output - 1213 Module2 (run) x run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt.…
- import java.util.Scanner; public class LabProgram { /* Define your method here */ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }}import java.util.Scanner; public class AutoBidder { public static void main (String [] args) { Scanner scnr = new Scanner (System.in); char keepGoing; int nextBid; nextBid = 0; keepGoing 'y'; * Your solution goes here */ while { nextBid = nextBid + 3; System.out.println ("I'll bid $" + nextBid + "!") ; System.out.print ("Continue bidding? (y/n) "); keepGoing = scnr.next ().charAt (0); } System.out.println (""); }1 import java.util.Scanner; 2 3 public class RedBalloon { public static void main (String 0 args) { Scanner scnr = new Scanner(System.in); boolean isRed; boolean isBalloon; 4 5 6 7 8 isRed = scnr.nextBoolean(); isBalloon = scnr.nextBoolean(); 9 10 11 12 13 } 15 } 14
- public class F { private boolean x; public class Test { public static void main (String[] args) { Ff = new F(); System.out.println(f.x); System.out .println(f. convert (f.x)); } public static void main(String[] args) { Ff = new F (); System.out.println (f.x); System.out.println(f.convert ()); private int convert(boolean b) { return x ? 1: -1; Is the above code in the classes above correct? Circle your answer choice: YES or NO If NO, write below the corrected code.import java.util.Scanner; public class Playlist { // TODO: Write method to ouptut list of songs public static void main (String[] args) { Scanner scnr = new Scanner(System.in); SongNode headNode; SongNode currNode; SongNode lastNode; String songTitle; int songLength; String songArtist; // Front of nodes list headNode = new SongNode(); lastNode = headNode; // Read user input until -1 entered songTitle = scnr.nextLine(); while (!songTitle.equals("-1")) { songLength = scnr.nextInt(); scnr.nextLine(); songArtist = scnr.nextLine(); currNode = new SongNode(songTitle, songLength, songArtist); lastNode.insertAfter(currNode); lastNode = currNode; songTitle = scnr.nextLine(); } // Print linked list…package go; package demo; public class Pokemon { import ; // import Pokemon class (#1) private int hitPoints; static int population; public class Main { public static void main(String[] args) { void attack() { // implementation this.evolve(); } public void evolve() { // implementation } } Pokemon pika = new Pokemon(); pika.hitPoints = 30; (#2) System.out.print(Pokemon.population);(#3) pika.attack(); (#4) pika.evolve(); (#5) } 1. How can we retrieve the value of hitPoints without allowing any other class to change its value? a) Change the access modifier of bitPoints to public b) Change the access modifier of hitPoints to default c) Make the hitPoints a static attribute d) Declare a new public method, say şetHitPoints(int value), that sets the value of hitPoints e) None of the above
- import javax.swing.JOptionPane; public class Addition{public static void main( String args[] ){for (int i = 0; i < 10; i++) {String Number = JOptionPane.showInputDialog( "Enter a number" );int number = Integer.parseInt( Number );int sum = number;JOptionPane.showMessageDialog( null, "The sum is " + sum,"Sum of 10 numbers", JOptionPane.PLAIN_MESSAGE );}}} I want to add the number that was entered but I don't know how to do that. Do you know how to add the entered number?public class Test { public static void main(String[] args) { int count = 1; while (count < 10) { } } } System.out.print(count % 2 ++count; // end while // end main == 1 ? "X" : "Y");Compute: z = y √x Ex: If the input is 4.0 3.0, then the output is: 1.0 1 import java.util.Scanner; 2 3 public class MathFunctions { 4 5 6 7 8 9 10 11 12 13 14 15 16 17} public static void main (String[] args) { Scanner scnr = new Scanner(System.in); double x; double y; double z; } X = scnr.nextDouble(); y scnr.nextDouble(); /* Your code goes here */ System.out.printf("%.1f\n", z); // This will output z with 1 decimal place. [