Question
Hello. Your help and great assistance are wonderful and great. Below is my Project 0 for the University of Pittsburgh. I require your help beginning
Hello. Your help and great assistance are wonderful and great. Below is my Project 0 for the University of Pittsburgh. I require your help beginning and completing my assignment. Although you are helping, tutoring, and assisting me complete this assignment I will still complete and re-write this assignment and all of my future assignments myself. Thank you for your tutoring, help, and assistance.
// This code (c) Jeff Cooper // Written in Spring 2020 for CS 0007
// This is an import statement. It imports something called java.util.Scanner, // which is used to read input from the command line. Despite its name, it has // nothing to do with the machine of the same name that scans printed documents // into the computer. import java.util.Scanner;
// This is the public class defined by this file // Notice that its name ("AssignmentOne") matches the name of the file // ("AssignmentOne.java")
public class AssignmentOne {
// This is the main method, which is what runs when we execute this program. public static void main(String[] args) { // This line defines a new scanner. Don't worry about exactly how it works, // we'll cover that in class soon. Scanner userInputScanner = new Scanner(System.in);
// This outputs "What is your name?" to the screen, followed by a // newline. This is similar to what we've seen in class. System.out.println("What is your name?")
// This defines a variable called "name", of type String. String variables // are used to store text. Instead of storing a literal string value in the // username variable, like we've done in lecture examples, this statement // gets a line of text from the user and stores that. In this case, a "line" // of text is "everything the user types until they press enter." String name = userInputScanner.nextLine();
// This line calls the "scramble" function on the name variable, and stores // the result in a new variable called "scrambledName". String scrambledName = scramble(name);
// Finally, print out the value of scrambled name to the screen. System.out.print("Your scrambled name is: \""); System.out.print(scrambledName); System.out.println("\""); }
// Don't worry about stuff below this line. It defines a function that // scrambles up your username and returns an encoded version. I'll go over // what it's doing in lecture at some point after this assignment is due. // I've written this code to be intentionally hard to read. private static String scramble(String n) { char[] out = new char[n.length()]; for (int i = 0; i < n.length(); i++) { char c = n.charAt(n.length() - i - 1); if ('A' <= c && c <= 'Z') { c = (char)((c - 'A' + 13) % 26 + 'A'); } else if ('a' <= c && c <= 'z') { c = (char)((c - 'a' + 13) % 26 + 'a'); } out[i] = c; }
return new String(out); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started