Words.java 2 import java.util.Scanner; 3 4 public class Words 5 { public static void main(String[] args) 6. { Scanner in = new Scanner(System.in); String word = in.next(); 8 9. 10 word.charAt(0); char first = 11 String last = word.substring (word.length()-1); 12 System.out.println(word); 13 14 15 }
Q: 1. Place all the Menus in separate Methods. 2. Place computations in separate Methods and call the…
A: In cases where the question has multiple questions, we are needed to solve only one. We have here…
Q: package pwriter2; import java.util.Scanner; import java.io.*; public class Pwriter2 {…
A:
Q: public class ArrayMerge { static void arrayMerge(int a[], int b[]){ int c[] = new…
A: Please find the solution below
Q: This is for Java Programming In my code, I'm missing a new line at the end of an array. I'm not…
A: for (i = 0; i < n; i++) array[i] = scnr.nextInt(); a = scnr.nextInt();…
Q: import java.util.Scanner; 2 3 public class OrderTwoCities { 4 public static void main(String[] args)…
A: Declare a string variable to hold the third city, city3. Take user input for the third city and…
Q: import java.util.Scanner; public class RunBloodData { public static void main(String[] args) {…
A: INTRODUCTION: Import the required libraries. Create a class that contains methods that are required…
Q: import java.util.*; import java.lang.*; import java.io.*; class BinaryToDecimal { // *More…
A: Required: to complete the given code.
Q: 1 import java.util.Scanner; 2 3 public class DeclaringVariables { public static void main(String[]…
A: import java.util.Scanner; public class DeclaringVariables { public static void main (String[] args)…
Q: Explain this java code import java.util.Scanner; public class Main { public static void…
A: Note: Program contains one error (http://System.in) which was removed Before understanding the…
Q: 1. rewrite this coding in java to get correct output import java.util.*; public class Children {…
A: following are the things that were absent in the code 1) Main method was empty 2) There was no…
Q: import java.util.Scanner; //import java.util.Random; public class FinalExam3{ public static void…
A: Actually, Java is a high level programming language. And also object oriented . It Is a platform…
Q: Correct my codes in java //String import java.util.Scanner; class salary { double…
A: Sample Output
Q: 283902.1889792.qx3zay7 1 import java.util.scanner; 2 3 public class Typecasting { 1 tast passed…
A: Required:
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: 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: Ex. If the input is: 4 plates 100 spoons 200 cups 150 forks 200 the output is: 200 forks…
A: Actually, the code has given beneath:
Q: Convert program code from Java to C++ import java.util.Scanner; public class Nobel_Award {…
A: Solution: Note : Complete executable converted C++ code is attached at step - 3. 1.…
Q: import java.util.Scanner; // import library for scanner class public class weatherInput public…
A: - We need to highlight the correct code in the image provided.
Q: import java.util.Scanner; public class ThreeTestScore { int size = 10; //create arrays for 10…
A: The given code has some errors. The modified code is: class ThreeTestScore { int size =…
Q: 2. Given the following program: 10 import java.util.Scanner; 2 import java.lang. Math; 4 public…
A: In the given code, the predefined methods are Math.pow() and Math.sqrt()
Q: Could you please write this code in C language?? //class declaration public class matrix {…
A: Code Conveted to C Code #include <stdio.h>void print(int arr[][6]);int main (){ int n;…
Q: A contact list is a place where you can store a specific contact with other associated information…
A: In java if you are reading input with .next method then you will read string till first '\n'…
Q: import java.io.*; import java.util.stream.*; public class Solution { static class ListCell {…
A: Merge Sort is a Divide and Conquer algorithm. It divides the input array into two halves, calls…
Q: How can i make this data enter and enter as a table in java. Please dont use array import…
A: In Java, to print the results like a table structure we can use printf() method, it belongs to the…
Q: -ices.size(); import java,util.Scanners import java.util.Arraylisti publie class Cashilegister…
A: Code: private ArrayList<Double> prices = new ArrayList<>(); public int getCount() {…
Q: import java.util.Scanner; public class Shady RestRoom 2 { // Modify the code below public static…
A: Screenshot of the code: Sample Output: Sample Run 1: Sample Run 2: Code to copy:…
Q: 3. What would be the output of the following code: import java.util.*; public class Test { public…
A: The given problem has a code in Java language andthe requirement is to understand the code and then…
Q: import java.util.*; public class Main{ public static void main(String[] args) {…
A: The solution to the given problem is below.
Q: For any element in keysList with a value greater than 50, print the corresponding value in…
A: In java it is possible to declare the key and it’s corresponding element. In this program keys and…
Q: public class MyClass { public static void main(String args[]) id(1) id(2) "s26j9876" }; id(0) String…
A: Length of id[0] is 8index of 7 in id[2] is 68+6=14Length of id is 3 So final output is 143
Q: package pkg1; import java.util.Scanner, public class Main { public static void main(String[] args) {…
A: To change the given java program so that it terminates when the user entered -1. Java program to…
Q: I need some help with this code import java.util.*; public class CarCareChoice2 { // Modify the…
A: NOTE: It is not specifically mentioned to modify the given code into what so the given code is…
Q: Covert the Java in to C++ import java.util.*; public class Main { public static void main(String[]…
A: #include <iostream> using namespace std; int main(){ int a, b, c, r; cout << "Enter…
Q: import java.util.*; public class Watersort { Character top = null; //…
A: public static boolean solved( StackAsMyArrayList bottles[]){boolean solved =true;for(int…
Q: Convert this PROGRAM CODE from Java to C++. import java.util.Scanner; public class…
A: Required: Convert the given PROGRAM CODE from Java to C++.
Q: Fix the Java code below, make sure it can make the same outputs as the sample: import…
A: Code with Output is given below : NOTE : Code have been modified according to the output given.
Q: What is output? import java.util.ArrayList; public class SimpleCar { @Override public String…
A: Given:
Q: Java
A: import java.util.Scanner; public class WordProperties { public static void…
Q: w int[a.length]; for(int i = 0; i < a.length; i++) { for(int j = 0; j < b
A: explained as,
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: import java.util.Scanner; public class MP2{ public static void main (String[] args){…
A: Find Your Code Below
Q: How do I fix the error Java? ReceiptMaker.java:6: error: invalid method declaration; return type…
A: Note: your given contain does not contain any ItemClass(String name, double price) method. If…
Q: Step 1: Import Java classes Arrays, Random, and Scanner /** * A class to generate a random int array…
A: The exception, InputMismatchException is a java in-built exception class and it is in the java. util…
Q: please check my JAVA code. One of my test cases is wrong. The question is as stated in the image…
A: One of your test cases didn't execute because the given code is not checking the case where the…
Q: (USE JAVA LANGUAGE) Kindly modify, add on where it is lacking and execute the java program provided…
A: Hi, I am an android developer. So I am implementing this star.java with some advanced feature. The…
Q: 1 import java.util.Scanner; 2 3 public class MaxOf Two { 4 5 6 7 8 9 .0 1 _2 min 6 3 4 5 -6 7 .8 _9}…
A: In method getUserValues, we will use for loop that varies from 0 to array size -1 to input array…
Q: import javax.swing.JOptionPane; public class Addition { public static void main( String args[] ) {…
A: you are not calculating the sum in your code. you are just assigning the number to sum every time…
Q: NameSorter.java Name.java import java.util.Scanner; import java.util.ArrayList; import…
A: code: import java.util.*;public class Main{ public static void main(String[] args) { Scanner scnr =…
Q: The String class is provided in the Java library. Provide your own Java implementation for the…
A: Explanation: charAt() The charAt () function of the Java-String class produces the character…
Q: import java.util.*; import java.io.*; public class Assignment public static void main(String args[])…
A: The above program is provided in Java language has one error
Complete this
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Beginner Java import java.util.Arrays;import java.util.Scanner; Arrays and scanner required. Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 65 pizza 100 45.75 70 5.8 5 Also suppose that you have two integers n and m that are both positive. For example: n = 5 and m = 10 Write a static method: public static double partialSum(Scanner s, int n, int m) that takes a Scanner and two integers n and m as arguments and returns the sum of the integers read by the Scanner that are divisible by n and not divisible by m. In the above example, the integers divisible by 5 and not divisible by 10 are 65 and 5, so the result would be 70. If the Scanner is empty, or no tokens are valid integers, the result should be 0. You can assume the Scanner is not null. It is probably easiest to test your method by creating a Scanner with a String instead of System.in. The starter code for an example of how to do this is…import java.util.Scanner; public class ContactList { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); ContactNode head = null; ContactNode current = null; // Read the name and phone number for three contacts and build a linked list. for (int i = 1; i <= 3; i++) { System.out.print(" " + i + ": "); String name = scnr.next(); System.out.print(" " + i + ": "); String phoneNumber = scnr.next(); ContactNode newContact = new ContactNode(name, phoneNumber); if (head == null) { head = newContact; current = head; } else { current.insertAfter(newContact); current = newContact; } } // Output each contact. current = head; for (int i = 1; current != null; i++) { System.out.print("Person " + i + ": "); current.printContactNode();…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);…
- 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…For any element in keysList with a value smaller than 50, print the corresponding value in itemsList, followed by a space. Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 10 40 import java.util.Scanner; public class Compare { public static void main(String args[]) { final int SIZE_LIST = 4; int[] keysList = new int[SIZE_LIST]; int[] itemsList = new int[SIZE_LIST]; int i; Scanner input = new Scanner(System.in); keysList[0] = input.nextInt(); keysList[1] = input.nextInt(); keysList[2] = input.nextInt(); keysList[3] = input.nextInt(); itemsList[0] = input.nextInt(); itemsList[1] = input.nextInt(); itemsList[2] = input.nextInt(); itemsList[3] = input.nextInt(); //answer// System.out.println(); } }import java.util.Scanner;import java.util.ArrayList; public class PhotoLineups { // TODO: Write method to create and output all permutations of the list of names. public static void printAllPermutations(ArrayList<String> permList, ArrayList<String> nameList) { } public static void main(String[] args) { Scanner scnr = new Scanner(System.in); ArrayList<String> nameList = new ArrayList<String>(); ArrayList<String> permList = new ArrayList<String>(); String name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method. }}
- Fix the Java code below, make sure it can make the same outputs as the sample: import java.util.ArrayList;import java.util.Scanner; class Main{ //Returns index of name if found otherwise -1 public static int findName(ArrayList<String> arr, String name) { for(int i = 0; i < arr.size(); i++) if(arr.get(i).equals(name)) return i; return -1;//Name not found } //Deletes a name from ArrayList public static void deleteName(ArrayList<String> arr, String name) { int index = findName(arr, name);//Get index of name to be deleted for(int i = index; i < arr.size() - 1; i++){ arr.set(i, arr.get(i + 1)); } arr.remove(arr.size() - 1);//Remove last element } public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter number of students(upto 10): "); int n = scan.nextInt(); ArrayList<String> arr = new…In Java import java.util.Scanner; public class ShoppingList { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); ItemNode headNode; // Create intNode objects ItemNode currNode; ItemNode lastNode; String item; int i; // Front of nodes list headNode = new ItemNode(); lastNode = headNode; int input = scnr.nextInt(); for(i = 0; i < input; i++ ){ item = scnr.next(); currNode = new ItemNode(item); lastNode.insertAtEnd(headNode, currNode); lastNode = currNode; } // Print linked list currNode = headNode.getNext(); while (currNode != null) { currNode.printNodeData(); currNode = currNode.getNext(); } } } ----------------------------------------- public class ItemNode { private String item; private ItemNode nextNodeRef; // Reference to the next node public ItemNode() { item = ""; nextNodeRef = null; } // Constructor public ItemNode(String itemInit) { this.item = itemInit; this.nextNodeRef = null; } // Constructor public…import java.util.* ; public class Averager { public static void main(String[] args) { //a two dimensional array int[][] a = {{5, 9, 3, 2, 14}, {77, 44, 22, 15, 99}, {14, 2, 3, 9, 5}, {88, 15, 17, 121, 33}} ; System.out.printf("Average = %.2f\n", average(a)) ; System.out.println("EXPECTED:") ; System.out.println("Average = 29.85") ; System.out.printf("Average of evens = %.2f\n", averageEvens(a)) ; System.out.println("EXPECTED:") ; System.out.println("Average of evens = 26.57") ; Random random = new Random(1) ; a = new int[100][1] ; for (int i = 0 ; i < 100 ; i++) a[i][0] = random.nextInt(1000) ; System.out.println("For an array of random values in range 0 to 999:") ; System.out.printf("Average = %.2f\n", average(a)) ; System.out.printf("Average of evens = %.2f\n", averageEvens(a)) ; } /** Find the average of all elements of a two-dimensional array @param aa the two…
- import java.util.Scanner; public class ShoppingList { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); ItemNode headNode; // Create intNode objects ItemNode currNode; ItemNode lastNode; String item; int i; // Front of nodes list headNode = new ItemNode(); lastNode = headNode; int input = scnr.nextInt(); for(i = 0; i < input; i++ ){ item = scnr.next(); currNode = new ItemNode(item); lastNode.insertAtEnd(headNode, currNode); lastNode = currNode; } // Print linked list currNode = headNode.getNext(); while (currNode != null) { currNode.printNodeData(); currNode = currNode.getNext(); } }}import java.util.Scanner; public class CharMatch { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String userString; char charToFind; int strIndex; userString = scnr.nextLine(); charToFind = scnr.next().charAt(0); strIndex = scnr.nextInt(); /* Your code goes here */ }}For any element in keysList with a value greater than 40, print the corresponding value in itemsList, followed by a semicolon (no spaces). Ex: If the input is: 32 105 101 35 10 20 30 40 the output is: 20;30; import java.util.Scanner; public class Compare { public static void main(String args[]) {final int SIZE_LIST = 4;int[] keysList = new int[SIZE_LIST];int[] itemsList = new int[SIZE_LIST];int i;Scanner input = new Scanner(System.in); keysList[0] = input.nextInt();keysList[1] = input.nextInt();keysList[2] = input.nextInt();keysList[3] = input.nextInt(); itemsList[0] = input.nextInt();itemsList[1] = input.nextInt();itemsList[2] = input.nextInt();itemsList[3] = input.nextInt(); /* Your code goes here */ System.out.println();} }