import java.io.*; public class ReadConsole { public static void main(String args[]) throws IOException { InputStreamReader cin = null; try { cin = new InputStreamReader(System.in); System.out.println("Enter characters, 'q' to quit."); char c; do { C = (char) cin.read(); System.out.print(c); } while(c != 'q'); }finally { if (cin != null) { cin.close(); } } }
Q: Write a program that takes a first name as the input, and outputs a welcome message to that name Ex:…
A: Code : import java.util.Scanner; public class LabProgram { public static void main(String[]…
Q: 1 import java.io.*; 3v public class Main public static void main(String[] args) throws IOException 5…
A: Let's understand step by step : 1. public static void main(String args[]) throws IOException This…
Q: Read the following second main class. Guess its output. class Test { public static void…
A: Introduction Read the following second main class. Guess its output. class Test { public static…
Q: How do I fix the errored outputs Java? Code: //import java.util.Arrays; //Movie.java public class…
A: import java.util.Arrays; public class Movie { private String movieName; private int numMinutes;…
Q: Write a java program that simulates a vending machine. Products can be purchased by inserting coins…
A: ======Coins.java======== package vendingmachine; public class Coins { // data members…
Q: package pwriter2; import java.util.Scanner; import java.io.*; public class Pwriter2 {…
A:
Q: please write it in C language. import java.util.*; public class EightQDfs { final int…
A: Step 1: Declare the function dispSol() that takes board configuration in the form of a…
Q: Each row of the csv file contains the showtime, title, and rating of a movie. Assume data of the…
A: Solution: Given,
Q: What will be the output of the following Java code? And Explain.? class char_increment {…
A: Given Program:- What will be the output of the following Java code? And Explain.? class…
Q: Write the Java program: Make sure to have proper code indentation. Code: class Main { public…
A: class Tile{ char letter; int value; //Constructor Tile(char l, int v) {…
Q: import java.util.*;public class TestAverage {public static void main(String[] args) {int test1,…
A:
Q: Many user-created passwords are simple and easy to guess. Write a program that takes a simple…
A: CODE:
Q: Explain everyline of this code.
A: import java.util.*; // importing the required packagepublic class Main // initializing the…
Q: Write a Java program called Div that takes 2 (two) double command-line arguments as inputs, dividend…
A: Write a JAVA program called Div that takes two inputs dividend and divisor and performs the Division…
Q: (c) public static void mC(int[) m) { for (int į = 0; i = 0; ) System.out.print (m(i)); (d) public…
A: According to the provided information: We need to find out the time complexity using Big O notation.
Q: Eclipse Java: Write a program that reads a string (password) and a number. The maximum number of…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: (in java) add a part where you print user information and update the continue watching list in…
A: Here , we have given the java class named Netflix. We need to create the two objects of this class…
Q: public class Student { private double myGPA; private int myID; . . . public getID( ) { return myID;…
A: Insert XXX to output the student's ID. public class Student {private double myGPA;private int…
Q: import java.util.*; public class Main public static boolean isALetter (char letter){ if( (letter =…
A: Some of the more advanced Java byte-code obfuscators do much more than just class name mangling. For…
Q: Write a program that takes in a line of text as input, and outputs that line of text in reverse. The…
A: ANSWER:-
Q: Write a java program that simulates a vending machine. Products can be purchased by inserting coins…
A: public class Coins { // data members private String typeofcoin; private double value; //…
Q: modify the java program below to use try-catch logic to detect input errors and display an error…
A: Given code: import javax.swing.*; public class Main { public static void main(String[] args) {…
Q: Write a recursive method that displays a string reversely on the console using the following header:…
A: Reverse a String using recursion. The required Java program is implemented below. Recursion Logic :…
Q: You are required to implement a preprocessor in Java. Your preprocessor should be able to perform…
A: package program.PPK; import java.io.BufferedReader; import java.io.File; import…
Q: package Rayjack_Lab03; import java.util.Scanner; public class RayJack_Lab03 { public static void…
A: nextInt() function in Scanner package is used to take an integer as input. In order input decimal…
Q: What is the output for the following java code? class Student { private int age public Student() {…
A:
Q: Explain the following code. import java.text.DecimalFormat; public class Time1 extends Object {…
A: The given is the Java code written in Time1 class that inherits the Object class. It has various…
Q: Examine the code and write - What is the content of the first 100 characters of text at the end of…
A: Answer : // these are the imports needed to run the program import…
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: In this java code, please create a flowchart. thank you Soure Code: import java.util.*; public…
A: As per the requirement flowchart is developed.
Q: Find the Output: output1-1(2).png ... import java.util.Scanner; public class outputl{ public static…
A:
Q: JAVA - Please produce both a product.java file and a productprinter.java file (tester) Implement a…
A: public class mainClass { public static void main(String[] args) { emp pcost = new emp();…
Q: xplain in your own words how one important method of your program above works.
A: A method is a process to carry out some tasks. Essentially, the strategy in Java is an assortment of…
Q: Write a recursive method that converts a positive decimal number to into a binary number as a…
A: Program in Java: import java.util.*; import java.lang.*; import java.io.*; class DecimalToBinary {…
Q: Many user-created passwords are simple and easy to guess. Program that takes a simple password and…
A: Note: Below is the required java program Programming Approach: Importing necessary package.…
Q: Write a java class that implements the following pseudocode · Start · Read number N, · Set remainder…
A: Programming instruction: Create a class. Read the input from the user. Calculate remainder as N…
Q: Translate this JAVA program to C++ programming language: import java.util.Scanner; class HelloWorld…
A: As per the requirement code is converted in to c++. Algorithm: Step 1: Write the main method Step 2:…
Q: import java.util.Scanner; oPrinter.ja public class PrintTableDemo public static void…
A: - We need to highlight the code for matching the output as provided.
Q: Please add Algorithm and comments to my program. Thank you public class Great { public static…
A: Algorithm: Start Declare a double array 'numbers' with size 10 Read 10 numbers as string and then…
Q: c. Show the output of the following Java program: 1 class ExceptionHandling { public static void…
A: According to the asked question, the solution is given below with a proper explanation.
Q: Question 1: Write a complete Java program - with your own code writing - that contains: 1. A main…
A: I have provided solution for Q1 of Part1)----- I have provided JAVA CODE along with CODE…
Q: hange Java code below so that it outputs a 9x9 board and not a 3x3 board. import java.util.*;…
A: Change Java code below so that it outputs a 9x9 board and not a 3x3 board.
Q: Java - public static void test_a(int n) {…
A: Java Sun Microsystems initially introduced Java, a programming language and computing platform, in…
Q: What will be the output of the following Java code? class average { public static…
A: Question. What will be the output of the following Java code? class average {…
Q: Consider the following Java program, and convert myFunction() method to iterative style (using…
A: public class MyClass{ //recursive method /* //lets first understand what this method does…
Q: class overload int x; double y; void add(int a , int b) { x - a + b; } void add(double c , double d)…
A: The Answer is in given below steps
Q: Java - How can I output the following statement as a single line with a newline? Program below.…
A: Output already comes in single line. But if you want to print each number on single line.It is…
Q: Write a program in c++that reads a positive integer n, and prints the first n even numbers. For…
A:
Q: Why the given Java code is not getting compiled and giving error? Remove the errors as well. class…
A: There are two errors in the given code: The first error is the wrong initialization of the array.…
Q: import java.util.*; 2 usages public class Main public static void main(String[] args) { Scanner sc =…
A: - We have the problem for parsing the string. - Just copy the complete code and it will surely…
Q: Java - public static void test_b(int n) { if (n>0)…
A: Given Java program is, public static void test_b(int n) { if…
Q: Change the program from the previous example to take command line arguments instead of using the…
A: import java.util.Scanner;public class main{public static void main(String[] args){Scanner sc = new…
Q: import java.util.Scanner; public class output1{ static void main(String[ ] args){ public double [] A…
A: EXPLANATION:- 1. Two arrays named A & B are declares. 2. A will have all values 0 initially. 3.…
Q: Please help me make this Encryption and decryption java code uncrackable Some ideas that I have in…
A: Program Plan: Define encryptMsg() method to encrypt the original message. Define decryptMsg()…
Run this
Step by step
Solved in 3 steps with 1 images
- import java.util.Random; class Main { public static void main(String[] args) { Random rand = new Random(); int a = new int[100]; for (int i = 0; i < 100; i++) { a[i] = rand.nextInt(100); } print(a); System.out.println("---"); quicksort(a, 0, a.length - 1); print(a); } public static void print(int[] a) { for (int x : a) { System.out.println(x); } } public static void swap(int[] a, int p1, int p2) { int temp = a[p1]; a[p1] = a[p2]; a[p2] = temp; } public static int partition(int[] a, int left, int right) { int pivot = right; int p1 = left; int p2 = pivot - 1; while (p2 >= p1) { if (a[p1] > a[pivot]) { swap(a, p1, p2); swap(a, p2, pivot); p2 = pivot - 1; } else { p1++; } } return pivot; } public static void quicksort(int[] a, int left, int right) { if (left < right) { int p = partition(a, left, right); quicksort(a, left, p - 1);…Please sort out the following JAVA code....line by line. Run the code in Netbeans and provide screenshots to verify that it runs successfully. CODE: import java.io.*; import java.util.*; public class experiment { public static void main(String args[]) { Scanner in=new Scanner(System.in); int time[]=new int[10]; float weight[]=new float[10]; String get; char ch; int i=0; do{ try { System.out.print("\nEnter the time in seconds:"); time[i]=in.nextInt(); System.out.print("\nEnter the weight in kilograms:"); weight[i]=in.nextFloat(); i++; } catch(Exception e) { System.out.print("\nInvalid type"); } System.out.print("\n-----------------"); System.out.print("\n|Time\t|Weight\t|"); System.out.print("\n-----------------"); for(int x=0;x<i;x++) { System.out.print("\n|"+time[x]+"\t|"+weight[x]+"\t|"); System.out.print("\n-----------------"); } if(i==10) { for(int x=0;x<9;x++) { time[x]=time[x+1]; weight[x]=weight[x+1]; } i--; } System.out.print("\nDo you want to continue?(y/n) ");…I need help with this Java Problem as described in the image below: import java.util.Scanner;import java.io.PrintWriter;import java.io.StringWriter; public class StringStreamOutput { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userItem; StringWriter itemCharStream = new StringWriter(); PrintWriter itemsOSS = new PrintWriter(itemCharStream); System.out.println("Enter items (type Exit to quit):"); userItem = scnr.next(); while (!userItem.equals("Exit")) { /* Your solution goes here */ userItem = scnr.next(); } userItem = itemCharStream.toString(); System.out.println(userItem); }}
- JAVA Program ASAP Please modify this program and take out the main method from the program so it passes the test cases in Hypergrade. I have provided the failed test cases. import java.io.BufferedReader;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.Arrays;import java.util.InputMismatchException;import java.util.Scanner;public class FileSorting { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("Please enter the file name or type QUIT to exit:"); String fileName = scanner.nextLine(); if (fileName.equalsIgnoreCase("QUIT")) { break; } try { ArrayList<String> lines = readFile(fileName); if (lines.isEmpty()) { System.out.println("File " + fileName + " is empty."); } else { performSorting(lines);…In JAVA: Show the contents of the file temp.txt after the following program is executed. (HINT: %e is exponential float, %b is boolean) public class Test { public static void main(String[] args) throws java.io.IOException { java.io.PrintWriter output = new java.io.PrintWriter("temp.txt"); output.printf("amount is %f %e\r\n", 32.32, 32.32); output.printf("amount is %5.4f %5.4e\r\n", 32.32, 32.32); output.printf("%6b\r\n", (1 > 2)); output.printf("%6s\r\n", "Java"); output.close(); } }Many user-created passwords are simple and easy to guess. Program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input is: mypassword the output is: Myp@ssw.rdq*s IN JAVA. USING LOOPS
- import java.util.*;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);}}a. Briefly explain what this code does.b. There is one logic error in this code explain what is wrong and how to fix it.import java.util.Scanner; public class OutputWithVars { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userNum; int userA; int userB; System.out.println("Enter integer:"); userNum = scnr.nextInt(); userA = userNum * userNum; userB = userNum * userNum * userNum; System.out.printf("You have entered %d", userNum); System.out.printf("\n%d squared is %d", userNum, userA); System.out.printf("\nAnd %d cubed is %d", userNum, userB); System.out.println("\nEnter another integer:"); int user = scnr.nextInt(); System.out.printf("%d", user) Purpose: I am trying to stop and let the user input another value but my result is Enter integer: You have entered 2 2 squared is 4 And 2 cubed is 8 Enter another integer: meaning my first part worked but... Exception in thread "main" java.util.NoSuchElementException at java.base/java.util.Scanner.throwFor(Scanner.java:937) at…please write it in C language. import java.util.*; public class EightQDfs { final int X = 4; void dispSol(int brd[][]) { for(int i = 0; i < X ; i++) { for(int j=0 ; j < X ; j++) { System.out.print(" " + brd[i][j]) + " "); System.out.println(); } } boolean isSafe(int brd[][] , int r , int c) //r is for row and c is column { int i , j; for(i = 0 ; i < c ; i++) if(brd[r][i] == 1) return false; for(i = r ; j = c ; i >=0 && j >= 0 ;i-- ,j--) if(brd[i][j] == 1) return false; for(i = r , j = c ; j >= 0 && i < X ; i++ , j--) if(brd[i][j] == 1) return false; return true; } boolean EQsolved(int brd[][] , int c) { if(c >= X) return true; for(int i= 0; i < X ;i++) { if(isSafe(brd , i , c)) { brd[i][c] = 1; if(EQsolved(brd , c + 1) == true ) return true; brd[i][c] = 0 ; } } return false; } boolean…
- JAVA - Please produce both a product.java file and a productprinter.java file (tester) Implement a class Product. A product has a name and a price, for example new Product("Toaster", 29.95). Supply methods getName, getPrice, and reducePrice. Supply a program ProductPrinter that makes two products, prints each name and price, reduces their prices by $5.00, and then prints the prices again.Explain this java code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(http://System.in); int[][] seats = new int[10][4]; System.out.println("Bus Seat Reservation:"); while (true) { System.out.println("Col 1 Col 2 Col 3 Col 4"); for (int i = 0; i < seats.length; i++) { System.out.print("row " + (i + 1) + " | "); for (int j = 0; j < seats[i].length; j++) { System.out.print(seats[i][j] == 0 ? "* " : "X "); } System.out.println(); } System.out.print("Enter row and column no. to reserve separated by space (enter negative no. to exit): "); int row = in.nextInt(); int column = in.nextInt(); if (row < 0 || column < 0) { System.out.print("Program Exit"); break; } seats[row - 1][column…The following code; import java.io.File; import java.util.*; public class BinarySearch { public static int search(int key, int[] a) { return search(key, a, 0, a.length); } public static int search(int key, int[] a, int lo, int hi) { if (hi <= lo) return -(hi-1); int mid = lo + (hi - lo) / 2; int cmp = a[mid]-key; if (cmp > 0) return search(key, a, lo, mid); else if (cmp < 0) return search(key, a, mid + 1, hi); else{ if (a[mid+1]==key) return search(key,a,mid+1,hi); else{ return mid; } } } public static void main(String[] args) { String name= args[0]; int count=0; try{ Scanner scanner = new Scanner(new File(name)); while(scanner.hasNextInt()) { scanner.nextInt(); count++; } } catch(Exception e){} int a[] = new int[count]; int in=0; try{ Scanner scanner1 = new Scanner(new File(name)); while(scanner1.hasNextInt()) a[in++]=scanner1.nextInt(); } catch(Exception e){} System.out.println(search(Integer.parseInt(args[1]),a)); } } Do not know how to correct the error; Exception in…