
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
![Assign the size of userlnput to stringSize. Ex: if userlnput is "Hello", output is:
Size of userInput:
1 import java.util.Scanner;
2
3 public class StringSize {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userInput;
int stringSize;
4
5
8
9.
userInput
scnr.nextLine();
%3D
10
11
/* Your solution goes here
*/
12
13
System.out.println("Size of userInput:
+ stringSize);
14
15
return;
}
16
17 }](https://content.bartleby.com/qna-images/question/96e8a255-6b70-420c-b5ef-4b46ae1f8d5e/e2c120da-cd70-4149-8f26-4561cabc2b0b/xb2tn7_thumbnail.png)
Transcribed Image Text:Assign the size of userlnput to stringSize. Ex: if userlnput is "Hello", output is:
Size of userInput:
1 import java.util.Scanner;
2
3 public class StringSize {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userInput;
int stringSize;
4
5
8
9.
userInput
scnr.nextLine();
%3D
10
11
/* Your solution goes here
*/
12
13
System.out.println("Size of userInput:
+ stringSize);
14
15
return;
}
16
17 }
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- How do I fix the Java code errors? Code: //import java.util.Arrays;//Movie.java package movie; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; public Movie() { movieName = "Flick"; numMinutes = 0; isKidFriendly = false; numCastMembers = 0; castMembers = new String[10]; } public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers) { this.movieName = movieName; this.numMinutes = numMinutes; this.isKidFriendly = isKidFriendly; this.numCastMembers = castMembers.length; this.castMembers = castMembers; } public String getMovieName() { return this.movieName; } public int getNumMinutes() { return this.numMinutes; } public boolean getIsKidFriendly() { return this.isKidFriendly; } public boolean isKidFriendly() {…arrow_forwardAssign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with false. 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 public class TeenagerDetector { publicstaticvoidmain (String [] args) { Scannerscnr=newScanner(System.in); booleanisTeenager; intkidAge; kidAge=scnr.nextInt(); if ( (kidsAge>13) && (kidsAge<19), { isTeenager=true; } elseif { isTeenager=false; } if (isTeenager) { System.out.println("Teen"); } else { System.out.println("Not teen"); }arrow_forwardJava - Insect Growtharrow_forward
- The provided file has syntax and/or logical errors. Determine the problem and fix the program.arrow_forwardGiven positive integer numInsects, write a while loop that prints, then doubles, numInsects each iteration. Print values = 1arrow_forwardconvert this code to JAVA location = [] size = [] rover = 0 def displayInitialList(location, size): global rover print("FSB# location Size") for i in range(len(location)): print(i," ",location[i]," ",size[i]) if rover<len(size)-1: print("Rover is at ",location[rover+1]) else: print("Rover is at ",location[rover]) def allocateMemory(location,size,blockSize): global rover if rover<len(size): while size[rover]<blockSize: rover+=1 if i==len(size): return False location[rover] += blockSize size[rover] -= blockSize rover+=1 return True else: return False def deallocateMemory(location,size,delLocation,delSize): i=0 while delLocation>location[i]: i+=1 location[i]-=delSize size[i]+=delSize while True: print("1. Define Initital memory\n2. Display initial FSB list\n3. Allocate memory\n4. Deallocate memory\n5. Exit") print("Enter choice: ",end="") choice = int(input()) if…arrow_forward
- Q: What's a better way to write this? (C#) public string SomeMethod(string OriginalZip) { string zip = "Zip Not Available"; zip = GetZip(zip, OriginalZip); return zip; } private static string GetZip(string zip, string OriginalZip) { int zipLength = (OriginalZip.HasValue) ? OriginalZip.Value.ToString().Length: 0; int NumOf Leading Zeroes = (zipLength > O && zipLength < 5) ? 5 - zipLength: 0; if (OriginalZip.HasValue) { i++) } zip = OriginalZip.Value.ToString(); for (int i = 0; i < NumOf Leading Zeroes; { } zip = "0" + zip; } return zip;arrow_forwardPlease help fastarrow_forwardHow do I make the code run properly? Code: import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor class movie{public static void main(String args[]){Movie obj=new Movie();Movie obj1=new Movie(obj.getMovieName(),obj.getNumMinutes(),obj.isKidFriendly(),obj.getCastMembers());System.out.println("Default Constructor: "+obj.getNumCastMembers());System.out.println("Overloaded Constructor: "+obj1.getNumCastMembers());}} // set the number of minutes public void setNumMinutes(int numMinutes) { this.numMinutes = numMinutes; } // set the movie name public void setMovieName(String movieName) { this.movieName = movieName; } // set if the…arrow_forward
- preLabC.java 1 import java.util.Random; 2 import java.util.StringJoiner; 3 4- public class preLabC { 5 6- 7 8 9 10 11 12 13 14 15 16 17 18 19 20 } public static String myMethod(MathVector inputVector) { String vectorStringValue = new String(); // empty String object System.out.println("here is the contents object, inputVector: + inputVector); // get a String out of that MathVector object. Do it here. On the next line. // return the double value here. return vectorStringValue; "1 ▸ Compilation Description A MathVector object will be passed to your method. Return its contents as a String. If you look in the file MathVector.java you'll see there is a way to output the contents of a MathVector object as a String. This makes it useful for displaying to the user. /** * Returns a String representation of this vector. The String should be in the format "[1, 2, 3]" * * @return a String representation of this vector * @apiNote **DO NOT** use the built-in (@code Arrays.toString()} method. */…arrow_forwardpackage Q2;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.util.ArrayList;import java.util.Scanner;public class Question2 {public static void main(String[] args) throws FileNotFoundException {/*** Part a* Finish creating an ArrayList called NameList that stores the names in the file Names.txt.*/ArrayList<String> NameList;/*** Part b* Replace null on the right-hand-side of the declaration of the FileInputStream object named inputStream* so that it is initialized correctly to the Names.txt file located in the folder specified in the question description*/FileInputStream inputStream = null;Scanner scnr = new Scanner(inputStream); //Do not modify this line of code/*** Part c* Using a loop and the Scanner object provided, read the names from Names.txt* and store them in NameList created in Part a.*//*** Part d* Reorder the names in the ArrayList so that they appear in reverse alphabetical order.*/// System.out.println("NameList after correct ordering: "…arrow_forwardMy issue: I don't know how to shift left after swapping arrays. My code: import java.util.Scanner;public class StudentScores {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);final int SCORES_SIZE = 4;int[] oldScores = new int[SCORES_SIZE];int[] newScores = new int[SCORES_SIZE];int i; for (i = 0; i < oldScores.length; ++i) {oldScores[i] = scnr.nextInt();} /* Your solution goes here */for (i=0; i < oldScores.length; i++) {newScores[i]= oldScores[i];}// student code ends here for (i = 0; i < newScores.length; ++i) {System.out.print(newScores[i] + " ");}System.out.println();}}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education