Hw1 (Simple I/O and Arithmetic Operations)

Hw1 (Simple I/O and Arithmetic Operations)

<p> HRS2422 Hw1 (Simple I/O and arithmetic operations) Directions:  Using WinZip or a similar program, Pack (compress) all of the assignment files into an archive called FirstName_LastNameHw1.zip. Make sure you take a snapshot of your output run on the command prompt window (use Alt+PrintScreen for PCs) and (Apple+Shift-3 for MACs) and save into a document called YourNameOutputRun.doc. Include the document in your Hw1 folder before you compress it.  Submit the zipped/compressed package/archive by using the computer science department submission server, as follows: a) Open My Computer and type the following URL in the Address box ftp:// cs.pitt.edu/khalifa/hrs2422/Hw1 b) To complete the submission, click and drag your compressed folder then release the mouse in the submission window. </p><p> Submission must be before the due date (by 11:59pm), otherwise, it will be considered late. </p><p>To compress your assignment: - Store all files in a folder called First_LastNameHw1 - Using windows XP do (Vista or the Mac could be slightly different): [Right-Click on the folder | Send To | Compressed (zipped) Folder] This will create First_LastNameHw1.zip inside your assignment folder.</p><p>See Hw-1 grading sheet for details on grading this hw (no need to submit the grading sheet—it will be handed to you with your hw grade recorded on it). </p><p>Programming Problem Part-1) Write a program that plays a word game with the user. The program should ask the user to enter the following:  Name, Age, City, College, and Profession After the user has entered these items, the program should display the following story, inserting the user’s input (should be entered in lower case letters then converted/displayed in upper case letters) into the appropriate locations: 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 PROFESSION. Hint-1:The String class has an API method called toUpperCase( );</p><p>Going back and forth to work, involved the following: Part-2) In the same pogram code, assume that the user works a certain number of hours each week with a fixed wage-rate, and travels a certain distance to work every day). Ask the user for the following information: - Pay per hour</p><p>- No. of work hours per week</p><p>- Distance travelled to work</p><p>Then compute the weekly salary of the user: Salary = Pay per hour * No. of work hours per week Now output all of this information to the screen (Weekly Salary and Distance travelled to work each day) Hint-2: Use appropriate datatypes for each variable, for example: ‘Name’ which is a sequence of characters would use the ‘string’ datatype, Salary would be of ‘float’ datatype, and Distance would be of datatype ‘double’)</p><p>1 Here’s also the skeleton code for the program: import java.util.Scanner;</p><p>// Name of the public class is the same as that of the program public class Hw1</p><p>{</p><p> public static void main(String args[])</p><p>{</p><p>// Declare your variables here, name is given as an example</p><p>String name;</p><p>// Read input using java's Scanner class</p><p>Scanner scan = new Scanner(System.in);</p><p>System.out.println ("Enter your name: ");</p><p> name = scan.next();</p><p>//Scan other variables here</p><p>// Compute Salary</p><p>// Output results to screen, similar to the example below</p><p>System.out.println ("Hello " + name);</p><p>}</p><p>}</p><p>2 HRS2422: Hw1</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us