import java.util.Scanner; public class String public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter your name : "); String name = sc.nextLine(); System.out.println("Enter your age : "); String age = sc.nextLine(); System.out.println("Enter your city : "); String city = sc.nextLine(); System.out.println("Enter your college : "); String college = sc.nextLine(); System.out.println("Enter your profession : "); String job = sc.nextLine(); System.out.println("Enter what type of animal you own : "); String animal = sc.nextLine(); System.out.println("Enter your pet's name : "); String pet = sc.nextLine(); int cityChars = city.length(); city = city.toLowerCase(); college = college.toUpperCase(); char cityFirstChar = city.charAt(0); System.out.println("there once was a person named " + name + " who lived in " + city + ". at the age of " + age + ", " + name +" went to college at " + college + "." + name+ " graduated and went to work as a " + job + ". Then, " + name+" adopted a (n) " + animal +" named " +pet+". they both lived happily ever after."); System.out.println(); System.out.println(city +"has"+cityChars+"characters."); System.out.println("in The first character of " + city + " is " + cityFirstChar); }
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question