nebmucoy674
Coder
I originally thought I had this one... Use scanner, get input from user, then concatenate it to a google search. My teacher stated the follow rules for URL's:
1. Replace +'s with %2B
2. Replace all spaces with +'s
3. Replace all "'s with %22
So here I am, doing what I thought was said, and obviously doing something wrong. I can just add the input to the end of the google link but am need to make a proper URL. Below is what I have, and thank you in advance for your help. As I said, I can just put the ("http://www.google.com/?q + one") and it works.
1. Replace +'s with %2B
2. Replace all spaces with +'s
3. Replace all "'s with %22
So here I am, doing what I thought was said, and obviously doing something wrong. I can just add the input to the end of the google link but am need to make a proper URL. Below is what I have, and thank you in advance for your help. As I said, I can just put the ("http://www.google.com/?q + one") and it works.
Java:
public class googleassignment {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("What would you like to search for:");
String one = scan.nextLine();
System.out.println(%22https://www.google.com/?q="+%2B+one%22);
}
}