Questions
Is there anyway to solve below problem in Java? Wherever there is int it gives an...

Is there anyway to solve below problem in Java?

Wherever there is int it gives an error! It's not only line 20! it give an runtime error everywhere get int after string! or even before read string!

cities[i] = sc.next(); //This way does not work!!!!

==============

input

San Francisco
Las Vegas
8
San Diego
Los Angeles
San Francisco
San Jose
Sacramento
Santa Barbara
Las Vegas
Pheonix
8 19
0 1
0 3
1 0
1 2
1 4
1 3
2 1
2 5
2 6
2 7
3 7
3 0
3 1
4 7
4 1
5 2
6 2
7 2
7 3

==============

Error:

==============

Exception in thread "main" java.util.InputMismatchException
        at java.util.Scanner.throwFor(Scanner.java:864)
        at java.util.Scanner.next(Scanner.java:1485)
        at java.util.Scanner.nextInt(Scanner.java:2117)
        at java.util.Scanner.nextInt(Scanner.java:2076)
        at Solution.main(myFuncs.java:20)

=======================

==============

import java.io.*;
import java.util.*;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;


public class myFuncs{

    public static void main(String arg[]) {
        Scanner sc = new Scanner(System.in);
        String s1, s2;
        s1 = sc.nextLine(); //first city
        s2 = sc.nextLine(); //second city
        int n = sc.nextInt(); //total number of cities
        String cities[] = new String[n];
        for (int i = 0; i < n; i++) {
            cities[i] = sc.nextLine(); //getting each city and storing them
        }
        n = sc.nextInt();
        int e = sc.nextInt();
        int adj[][] = new int[n][e];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < e; j++)
                adj[i][j] = 0;
        for (int i = 0; i < e; i++) {
            int c1 = sc.nextInt();
            int c2 = sc.nextInt();
            adj[c1][c2] = 1;
            adj[c2][c1] = 1;
        }

        int index1 = -1, index2 = -1;

        for (int i = 0; i < n; i++) {
            if (cities[i].equals(s1)) index1 = i; //storing the index of first city
            if (cities[i].equals(s2)) index2 = i; //storing the index of second city
        }

        adj[index1][index2] = 0;
        adj[index2][index1] = 0;


        System.out.println(cities[index1] + " " + index1);
        System.out.println(cities[index2] + " " + index2);


        if (bfs(adj, index1, index2, n)) System.out.println("true");
        else System.out.println("false");
    }

    public static boolean bfs(int adj[][], int source, int dest, int V) {

        boolean visited[] = new boolean[V];

        LinkedList < Integer > queue = new LinkedList < Integer > ();

        visited[source] = true;
        //visited[dest]=true;
        queue.add(source);

        while (queue.size() != 0) {

            int s = queue.poll();

            if (queue.size() != 0)
                queue.remove();

            System.out.print(s + " ");

            for (int i = s; i < V; i++) {
                if (adj[s][i] == 1 && !visited[i]) {
                    visited[i] = true;
                    queue.add(i);
                    if (i == dest) return true;
                }
            }

        }

        return false;
    }

}

In: Computer Science

If the statement is true, prove it. Otherwise give a counter example. a)If V=C3 and W1={(z1,z2,z2)∈C3:z1,z2∈C},...

If the statement is true, prove it. Otherwise give a counter example.

a)If V=C3 and W1={(z1,z2,z2)∈C3:z1,z2∈C}, W2={(0,z,0)∈C3:z∈C}, then V=W1⊕W2.

b)If Vis a vector space and W1, W2 are subspaces of V, then W1∪W2 is also a subspace of V.

c)If T:V→V is a linear operator, then Ker(T) and Range(T) are invariant under T.

d)Let T:V→V be a linear operator. If Ker(T)∩Range(T) ={0}, then V=Ker(T)⊕Range(T).

e)If T1,T2:VV are linear operators such that T1T2=T2T1, and λ2 is an eigenvalue of T2, then Ker(T2−λ2I) is invariant under T1.

In: Accounting

According to the author, what three kinds of information can be learned from international comparisons of...

According to the author, what three kinds of information can be learned from international comparisons of health care systems and What sorts of questions might arise about health care politics being common or different among countries? (500 words) In your own words No plagiarizm

In: Economics

In your reading assignment, “Engaging With Children and Young People” by Mary Kellett, the author suggested...

In your reading assignment, “Engaging With Children and Young People” by Mary Kellett, the author suggested methods for more effective communication.

Mention three “pearls” that you will utilize in practice involving general and/or specific pediatric populations.

https://epubs.scu.edu.au/cgi/viewcontent.cgi?article=1029&context=ccyp_pubs/

In: Nursing

Among the tools (such as graphics tools, knowledge-based tools, et cetera) that the author discussed in...

  • Among the tools (such as graphics tools, knowledge-based tools, et cetera) that the author discussed in the textbook, determine the type of tool that you would use for a process improvement framework. Next, determine the type of tool you would use for a problem-solving framework. Justify your response.

In: Statistics and Probability

Find an article relating to Cost of Capital or Capital Budgeting from any medium, briefly summarize...

Find an article relating to Cost of Capital or Capital Budgeting from any medium, briefly summarize the article, explain how you found the article particularly useful or timely, and give your personal reactions to the article. Be sure to provide the title of the article, the author(s), and the reference for the article.

In: Finance

-> present a topic related to healthcare, medical technology, or public health -> Provide at least...

-> present a topic related to healthcare, medical technology, or public health
-> Provide at least 3 journals or references that you would want to use in support of the topic that you have chosen.

The following information should be included:
- Title
- Year published
- Author/s
- key points of the journal

In: Nursing

IN C++ PLEASE: (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign...

IN C++ PLEASE:

(1) Extend the ItemToPurchase class per the following specifications:

  • Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0).
  • Public member functions
    • SetDescription() mutator & GetDescription() accessor
    • PrintItemDescription() - Outputs the item name and description in the format name: description
  • Private data members
    • string itemDescription - Initialized in default constructor to "none"

(2) Create three new files:

  • ShoppingCart.h - Class declaration
  • ShoppingCart.cpp - Class definition
  • main.cpp - main() function (Note: main()'s functionality differs from checkpoint A)

Build the ShoppingCart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be completed in later steps.

  • Default constructor
  • Parameterized constructor which takes the customer name and date as parameters
  • Private data members
    • string customerName - Initialized in default constructor to "none"
    • string currentDate - Initialized in default constructor to "January 1, 2016"
    • vector < ItemToPurchase > cartItems
  • Public member functions
    • GetCustomerName() accessor
    • GetDate() accessor
    • AddItem()
      • Has parameter ItemToPurchase. Does not return anything.
      • Adds the item to cartItems vector as long as the quantity is not zero.
    • IsItemInCart()
      • Has a string (an item's name) parameter. Checks if that item is in cart. If so, returns True else False.
      • Has an integer parameter passed by reference. If the item exists, populates it with index in cartItems vector. ((I ESPECIALLY NEED HELP WITH THIS PART PLEASE)))
    • RemoveItem()
      • Removes item from cartItems vector. Has a string (an item's name) parameter. Does not return anything.
      • If item name cannot be found, output this message: Item not found in cart. Nothing removed.
    • ModifyItem()
      • Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase with updated data members. Does not return anything.
      • If item can be found (by name) in the cart, check if the input parameter has default values for data members: description, price, and quantity. If not, modify that data member of the item in cart.
      • If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified.
    • GetNumItemsInCart()
      • Returns quantity of all items in cart. Has no parameters.
    • GetCostOfCart()
      • Determines and returns the total cost of items in cart. Has no parameters.
    • PrintTotal()
      • Outputs total of objects in cart.
      • If cart is empty, output this message: SHOPPING CART IS EMPTY
    • PrintDescriptions()
      • Outputs each item's description.

In: Computer Science

Suppose that 73% of Santa Ana residents are Latino. You select a sample of 18 residents?...

Suppose that 73% of Santa Ana residents are Latino. You select a sample of 18 residents? please use appropriate notation for each queation. for example: P(X=13) please also calculate your answers with 4 decimal places.

A) what is the probability that exactly 13 of the residents are Latino?
B) what is the probability that at most 15 residents are Latino?
C) what is the probability that between 10 and 16 residents are Latino?
D) what is the mean number of Latinos for a distribution of 18 residents. show your work no probability notation needed.
E) what is the standard deviation of Latinos for the distribution of 18 residents. show your work no probability notation needed?
F) using the mean and standard deviation from D and E is a sample of 18 with only nine Latinos considered unusual?

Compute without using combinations. please be neat and show all your work.

In: Statistics and Probability

Question 7 In Santa Monica, California, it was reported that a “finder’s fee”—an up-front payment of...

Question 7

In Santa Monica, California, it was reported that a “finder’s fee”—an up-front payment of up to $5,000—was being required of prospective tenants seeking to rent special apartments. What is this an example of?

the black market

a price floor

price gouging

a government price ceiling

Question 8

Mesa Petroleum Company built a small park in front of its corporate office. This is an example of __________.

imposing external costs on its shareholders

providing a pure public good

providing external benefits to the community

assuming city responsibilities

Question 9

What is the most frequently cited example of an externality?

service charges

public protest

pollution

sales taxes

Question 10

A negative externality exists when __________.

all costs are taken into account in the demand curve

all costs are taken into account in the supply curve

the market demand curve is not the true demand curve

the marginal social costs are not taken into account in the supply cur

In: Economics