Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Week 03: Lab 2 - Introductory Programming in Java Skip navigation Introductory Programming in Java ANU College of Engineering & Computer Science Search query Search ANU web, staff & maps Search COMP6700 Lectures Labs Assignments menu Search query Search ANU web, staff & maps Search Search COMP6700 labs Week 01: Welcome Week 02: Lab 1 Week 03: Lab 2 and HW 1 Week 04: Lab 3 and HW 2 Week 05: Drop-in Lab, HW 3 Week 06: Lab 4 and HW 4 Week 07: Mid-sem Exam Week 08: Free (Anzac Day) Week 09: Lab 5 and HW 5 Week 10: Lab 6 and HW 6 Week 11: Lab 7 and HW 7 Week 12: Lab 8 and HW 8 related sites Wattle Piazza Week 03: Lab 2 Objectives Write a few small Java programs which require conditional structures, operators and loops. Exercise One Write a program which reads in an integer from the user and then prints out the last digit of the number that is seven times the value which the user entered. For example, if a user enters the number 53, your program will compute the number 7*53=371 and print out the last digit which is 1. (Note that you will need to use the modulo division operator (%) in this program.) Exercise Two An examiner is using a grading scheme whereby the grade depends on the marks like this: 0-50 F 51-60 E 61-70 D 71-80 C 81-90 B 91-100 A Write a program that asks for a score (0-100) and reports the grade (F-A). Refine the previous program by making it to add a + or - after the grades E and above according to last digit as follows: 1-3 - 4-7 8-0 + This means that a mark of 93 is A-; 88 is B+; 65 is D and so on. Exercise Three Write a program that asks the user for a positive integer n and prints out an ASCII representation of an n×n grid like this (when n is 4): +--+--+--+ | | | | +--+--+--+ | | | | +--+--+--+ | | | | +--+--+--+ You should have one method to print the even rows and one method to print the odd rows. Write a similar program which prints out an ASCII triangle of a given height n, where n is an integer provided by the user. For example, for n == 3: + /| / | / | +---+ Further Programming Ideas Different functions of your programs (like calculating a desired number, or determining a grade, or printing a result etc.), should be implemented in different methods: this is called modularisation — one of the basic principles of programming. If you did not use methods in your solutions, but lumped everything into one main method, try extracting the different functions of your program into separate methods. Updated:  05 Mar 2017/ Responsible Officer:  Head of School/ Page Contact:  Alexei Khorev Contact ANU Copyright Disclaimer Privacy Freedom of Information +61 2 6125 5111 The Australian National University, Canberra CRICOS Provider : 00120C ABN : 52 234 063 906 You appear to be using Internet Explorer 7, or have compatibility view turned on. Your browser is not supported by ANU web styles. » Learn how to fix this » Ignore this warning in future