Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 2, Problem 11STE
Explanation of Solution
Given: The Scanner class and its object named as frank.
To find:Â The syntax of creating the Scanner class object frank.
Solution:
The Scanner is a class which is present inside the package java.util and is used in the program for taking the input from the console...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a line of code that creates a Scanner object named frank to be used forobtaining keyboard input.
Write a program to accept the length of and width of a rectangle using scanner class and display its area and perimeter By Using Inheritance? Note} area = length *width perimeter= 2* length + 2*width
I need help with fixing this java program as described in the image below:
import java.util.Scanner;import java.io.FileInputStream;import java.io.IOException;
public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in);
// Read the file name from the user String fileName = scnr.nextLine();
// Open the CSV file try (Scanner fileScanner = new Scanner(new FileInputStream(fileName))) { while (fileScanner.hasNextLine()) { // Read each line from the CSV file String line = fileScanner.nextLine();
// Split the line into showtime, title, and rating String[] movieData = line.split(",");
// Extract showtime, title, and rating String showtime = movieData[0]; String title = movieData[1].length() > 44 ? movieData[1].substring(0, 44) : movieData[1]; String rating = movieData[2];
// Print the…
Chapter 2 Solutions
Absolute Java (6th Edition)
Ch. 2 - Prob. 1STECh. 2 - Write Java statements that will cause the...Ch. 2 - What is the difference between System.out.println...Ch. 2 - Prob. 4STECh. 2 - What output is produced by the following code?
Ch. 2 - What output is produced by the following code? For...Ch. 2 - Write a Java statement to output the value in...Ch. 2 - What output is produced by the following code?...Ch. 2 - Suppose the class Robot is a part of the standard...Ch. 2 - Write an import statement that makes the Scanner...
Ch. 2 - Prob. 11STECh. 2 - Write a line of code that uses the object frank...Ch. 2 - Write a complete Java program that reads in a line...Ch. 2 - Write a complete Java program that reads in a line...Ch. 2 - Something could go wrong with the following code....Ch. 2 - Suppose your code creates an object of the class...Ch. 2 - Continue with the object keyboard from Self-Test...Ch. 2 - Prob. 18STECh. 2 - What is missing from the following code, which...Ch. 2 - The Babylonian algorithm to compute the square...Ch. 2 - (This is a version with input of an exercise from...Ch. 2 - Write a program that reads in two numbers typed on...Ch. 2 - John travels a distance of 55 miles at an average...Ch. 2 - Grade point average (GPA) in a 4-point scale is...Ch. 2 - (This is a better version of an exercise from...Ch. 2 - Write a program that determines the change to be...Ch. 2 - Write a program that reads in a string containing...Ch. 2 - (This is a better version of an exercise from...Ch. 2 - Write a program that inputs the name, quantity,...Ch. 2 - Write a program that calculates the total grade...Ch. 2 - (This is a variant of an exercise from Chapter 1.)...Ch. 2 - (This is an extension of an exercise from Chapter...Ch. 2 - From Programming Project 10 in Chapter 1,...
Knowledge Booster
Similar questions
- Write a program in Python that uses tkinter to display a window with 3 fields asking a user for their email, first name, and last name. Add 1 button named 'submit' that will open a file called 'subscription.txt' and append the three values to the end of the file.arrow_forwardplease edit this code so it does not contain breaks, while(true) and BufferedReader. Also keep getting this error " *** IOException *** phonebook.text (No such file or directory) the desired output has been given in the picture. here is the code to edit: import java.io.*; import java.util.Scanner; public class Phonebook { public static void main(String[] args) { int lookupCount = 0; int revLookupCount = 0; int phoneEntryCount = 0; Scanner inputReader = new Scanner(System.in); try { File file = new File("phonebook.txt"); BufferedReader phonebookReader; PhonebookEntry phonebookEntry[] = new PhonebookEntry[100]; phonebookReader = new BufferedReader(new FileReader(file)); String line = phonebookReader.readLine(); while (line != null) { if (phoneEntryCount >= 100) { throw new Exception( "Phonebook capacity exceeded - increase size of underlying array"); } phonebookEntry[phoneEntryCount++] = new PhonebookEntry(line); line = phonebookReader.readLine(); } phonebookReader.close(); mainLoop:…arrow_forwardUsing JAVA code: Please make a GUI that will convert infix to postfix expression. In the interface, please show also the process of the conversion (line by line).arrow_forward
- Create a TestTriangle class in an individual .java file. In the main method,(1) Create a Triangle object with default base and height values.(2) Create a Triangle object with specified base = 3 and height =4.arrow_forwardNOTE:- Please type this java code and need an output also, even explain how to work this code. (Also tell how to create the text file for this code if necessary please)arrow_forwardI just need help creating this Java code as described below in the image: import java.util.Scanner;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.PrintWriter;import java.io.IOException; public class LabProgram { public static void main(String[] args) throws IOException { Scanner scnr = new Scanner(System.in); /* TODO: Declare any necessary variables here. */ /* TODO: Read a file name from the user and read the tsv file here. */ /* TODO: Compute student grades and exam averages, then output results to a text file here. */ }}arrow_forward
- there are 2 errors in this code can you fix it for me? public class Exercise09_10 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a, b, c: "); double a = input.nextDouble(); double b = input.nextDouble(); double c = input.nextDouble(); QuadraticEquation equation = new QuadraticEquation(a, b, c); double discriminant = equation.getDiscriminant(); if (discriminant < 0) { System.out.println("The equation has no roots"); } else if (discriminant == 0) { System.out.println("The root is " + equation.getRoot1()); } else // (discriminant >= 0) { System.out.println("The roots are " + equation.getRoot1() + " and " + equation.getRoot2()); } } }arrow_forwardMake a text file with the matter of output image. Write a ajax program to fetch the txt file and print the below output .arrow_forwardPlease help how do I make the code show on the black screen instead of a txt.file. By the way I have already created a txt.file in this java compiler called Data.txtarrow_forward
- i need to load this file in and draw the circle using ONLY graphics.py, no turtle graphics please. I have these items so far. Not sure how to read in the file, and have it draw the circle by opening up a new window. def draw_circle(x, y, radius, color):c = Circle(Point(x, y), radius)c.setFill(color)c.draw(win) if line[0] == "circle":draw_circle(int(line[1]), int(line[2]),int(line[3]), (line[4]))arrow_forwardCreate a JavaFX application that uses a TextField to get a message and encode or decode it using the classes described in Programming Project 5. Use buttons to control the kind of cipher used and to specify whether to encode or decode the message. Also use a TextField to get the number used in the constructor for the ciphers.arrow_forwardWhy did we use the PrintStream and Scanner classes for file output and input, respectively? A They're the only classes available for file input and output. B They allow us to use the same input and output method call formats we used for keyboard input and display output. C Those are not classes we used for file input and output. D Only the PrintStream class can create a file that the Scanner class can read.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,