1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
natali 33 [55]
3 years ago
6

Assume that input file references a Scanner object that was used to open a file. Which of the following while loops shows the co

rrect way to read data from the file until the end of the file is reached?
a) while (inputFile != null)
b) while (!inputFile.EOF)
c) while (inputFile.hasnextInt())
d) while (inputFile.nextLine == " ")
Computers and Technology
1 answer:
12345 [234]3 years ago
4 0

Answer:

The correct answer to the following question is an option c) while (inputFile.hasnextInt()).

Explanation:

hasnextint() is the function of the scanner class which is "java.util.Scanner".

This method returns the boolean value so the data type of this method is boolean.

Integer values of radix are assumed only when a next token is in the Scanner input and it returns output True.

The other options are false because the input file can be null and the end of file is not equal to the input file and the next line is equal to the space and also the other options are not the object of the scanner class.

You might be interested in
write pseudocode to represent the logic of a program that allows the user to enter a value for one edge of a cube. The program c
PilotLPTM [1.2K]

Answer:

prompt("Enter a value for one edge of a cube")

Store user's value into edgeCube

area = 6 * (edgeCube * edgeCube)

volume = edgeCube * edgeCube * edgeCube

print("One side of the cube is: " + edgecube);

print("The area is: " + area)

print("The volume is: " + volume)

8 0
2 years ago
Create a class called StockTester that has the following fucntionality. a. Create a main method with an ArrayList named dataStoc
myrzilka [38]

Solution :

public class $\text{Stock}$ {

private $\text{String}$ stockName, $\text{purchaseDate}$;

private $\text{int}$ nShares;

private $\text{double}$ price;

 

public $\text{Stock}()$

{

this.stockName = "";

this.purchaseDate = "";

this.nShares = 0;

this.price = 0.0;

}

public Stock(String stockName, String purchaseDate, int nShares, double price) {

this.stockName = stockName;

this.purchaseDate = purchaseDate;

this.nShares = nShares;

this.price = price;

}

public String getStockName() {

return stockName;

}

public void setStockName(String stockName) {

this.stockName = stockName;

}

public String getPurchaseDate() {

return purchaseDate;

}

public void setPurchaseDate(String purchaseDate) {

this.purchaseDate = purchaseDate;

}

public int getnShares() {

return nShares;

}

public void setnShares(int nShares) {

this.nShares = nShares;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

 

public String toString()

{

return("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price));

}

 

public void printStock()

{

System.out.println("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price)

+ "\n");

}

}

StockTester.java (Driver class)

import $\text{java.io.}$File;

import $\text{java.io.}$File$\text{NotFound}$Exception;

import $\text{java.util.}$ArrayList;

import $\text{java.util.}$Scanner;

$\text{public}$ class StockTester {

 

private static final String FILENAME = "StockInfo$.$csv";

 

public static $\text{void}$ main($\text{String}[]$ args)

{

ArrayList$$ dataStock = $\text{readData}$(FILENAME);

 

System.out.println("Initial stocks:");

for(Stock s : dataStock)

s.printStock();

 

System.out.println("Adding a new Stock object to the list..");

Stock newStock = new Stock("Gamma", "03/01/20", 100, 50.5);

dataStock.add(newStock);

 

System.out.println("\nStocks after adding the new Stock..");

for(Stock s : dataStock)

s.printStock();

 

Stock targetStock = dataStock.get(3);

double reqReturn = requiredReturn(targetStock, 4000, 3);

System.out.println("Required rate of return = " + String.format("%.2f", reqReturn) + "%");

}

 

private static ArrayList<Stock> readData(String filename)

{

ArrayList<Stock> stocks = new ArrayList<>();

Scanner fileReader;

try

{

fileReader = new Scanner(new File(filename));

while(fileReader.hasNextLine())

{

String[] data = fileReader.nextLine().trim().split(",");

String stockName = data[0];

String purchaseDate = data[1];

int nShares = Integer.parseInt(data[2]);

double price = Double.parseDouble(data[3]);

 

stocks.add(new $\text{Stock}$(stockName, $\text{purcahseDate}$, nShares, price));

}

fileReader.close();

}catch(FileNotFoundException fnfe){

System.out.println(filename + " cannot be found!");

System.exit(0);

}

return stocks;

}

 

private static double requiredReturn(Stock s, double targetPrice, int years)

{

double reqReturn;

 

double initialPrice = s.getPrice() * s.getnShares();

reqReturn = ((targetPrice - initialPrice) / initialPrice * years) * 100;

 

return reqReturn;

}

}

3 0
2 years ago
CB workorder
elena-14-01-66 [18.8K]
The late seventeenth-century literary period known as the Restoration begins in 1660, the year in which the monarchy (and specifically, King Charles II) was restored to the English throne.
3 0
3 years ago
The beginning balance of Keyshawn's savings account for the month of September was $3900, and it remained this way for the first
Doss [256]
I’m not gonna wanna was that 638
4 0
2 years ago
Please help!!!!
alex41 [277]




Hi pupil here is your answer :::




➡➡➡➡➡➡➡➡➡➡➡➡➡



Your question :》 Which options are available when a user modifies a recurring appointment? check all that apply.


The answer is => A Open this occurenceand the option D Open the series are the option that shows from the dailog box that shows when attempting to modify the appointments .




⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅⬅




Hope this helps .........
8 0
2 years ago
Other questions:
  • What is life all about?
    15·2 answers
  • True or false words spelling and grammar check is always %100
    7·2 answers
  • How do I make Dank memes
    13·2 answers
  • You could be electrocuted if you try to use water to put out a
    14·2 answers
  • What are the two categories of problems that we can simply convert<br> to parallel code?
    10·1 answer
  • True or false? The History list shows only Web pages you visited during the current computing session. -computer essentials
    7·1 answer
  • When you press the ____ key without entering any text after the automatic bullet character, Word turns off the automatic bullets
    11·1 answer
  • This is using python.
    5·2 answers
  • What three best practices can help defend against social engineering attacks?
    13·1 answer
  • The ______ process retains copies of data over extended periods of time in order to meet legal and operational requirements.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!