Upload
m4i4nhb4o
View
220
Download
0
Embed Size (px)
Citation preview
8/11/2019 Chapter 02 Programming Challenges
1/21
Chapter 2Programming Challenges
8/11/2019 Chapter 02 Programming Challenges
2/21
1. Name and Initials
Name of a person usually consists of rstname, middle name, and last name.Develop a program that has the following
methods eturn the full name of that person. !or
e"ample, #$oang %he Nguyen#
eturn the author name for citing areference. !or e"ample, #Nguyen $.%.#
8/11/2019 Chapter 02 Programming Challenges
3/21
2. Name, &ge, and &nnualIncome
Develop an employee report that has thefollowing information
Name
&ge
&nnual pay
!or e"ample, 'r. (oe 'ahoney is 2) years
old. $e earns *1++,+++.+ per year
8/11/2019 Chapter 02 Programming Challenges
4/21
. Personal Information
Develop a program to representinformation of a person. %he informationshould include
Name &ddress -numer and street/ with city, state,
and 0IP
%elephone numer
College maor
8/11/2019 Chapter 02 Programming Challenges
5/21
http33www.nlm.nih.gov3services3fa4images3inst5address.pg
http://www.nlm.nih.gov/services/faqimages/inst_address.jpghttp://www.nlm.nih.gov/services/faqimages/inst_address.jpghttp://www.nlm.nih.gov/services/faqimages/inst_address.jpghttp://www.nlm.nih.gov/services/faqimages/inst_address.jpg8/11/2019 Chapter 02 Programming Challenges
6/21
6. 7um of %wo Numers
Develop a program to calculate the sumof two integers
8/11/2019 Chapter 02 Programming Challenges
7/21
8. 7ales %a"
Develop a program to calculate the saletotal y using the following formula
sale total 9 purchase amount : state
sales ta" -6;/ : county sales ta" -2;/
8/11/2019 Chapter 02 Programming Challenges
8/21
). 7tar Pattern
Develop a program that displays thefollowing pattern
*
***
*****
*******
*****
***
*
8/11/2019 Chapter 02 Programming Challenges
9/21
ne acre of land is e4uivalent to 6,8)+s4uare feet. Develop a program thatcalculates the numer of acres in a tract
of land with a given value in s4uare feet,for e"ample, ?@,
8/11/2019 Chapter 02 Programming Challenges
10/21
?. 7ales Prediction
%he Aast Coast sales division of acompany generates )2 percent of totalsales. Based on that percentage, develop
a program that will predict how muchAast Coast division will generate if thecompany has *6.) million in sales thisyear
8/11/2019 Chapter 02 Programming Challenges
11/21
@. 'ilesperallon
& carEs milespergallon -'P/ can ecalculated with the following formula
'P 9 'iles driven 3 allons of gas used
Develop a program to calculate the carEs'P
8/11/2019 Chapter 02 Programming Challenges
12/21
1+. Circuit Board Prot
&n electronics company sells circuitoards at a 6+ percent prot. If you Fnowthe retail price of a circuit oard, you can
calculate its prot with the followingformula
Prot 9 etail price G +.6
Develop a program to calculate theamount of prot earned for that product
8/11/2019 Chapter 02 Programming Challenges
13/21
8/11/2019 Chapter 02 Programming Challenges
14/21
12. estaurant Bill
Develop a program that computes theta", tip and total on a restaurant ill. %heta" should e ).
8/11/2019 Chapter 02 Programming Challenges
15/21
1. 7tocF Commission
Hathryn ought )++ shares of stocF at aprice of *21.
8/11/2019 Chapter 02 Programming Challenges
16/21
16. 7tring 'anipulator
iven the name of a city, develop aprogram that provides the following
%he numer of characters in the city name
%he name of the city in all uppercase letters %he name of the city in all lowercase letters
%he rst character in the name of the city
8/11/2019 Chapter 02 Programming Challenges
17/21
18. Anergy DrinF Consumption
& soft drinF company recently surveyed12,6)< of its customers and found thatappro"imately 16 percent of those
surveyed purchase one or more energydrinFs per weeF. >f those customers whopurchase energy drinFs, appro"imately )6percent of them prefer citrusavored
energy drinFs. Develop a program thatcalculates the following
%he appro"imate numer of customers in thesurvey who purchase one or more energy
drinFs per weeF
8/11/2019 Chapter 02 Programming Challenges
18/21
1). 7tocF %ransaction Program =ast month (oe purchased some stocF in
&cme 7oftware, Inc. $ere are the detailsof the purchase
%he numer of shares that (oe purchased was1,+++
Jhen (oe purchased the stocF, he paid*2.?< per share
(oe paid his stocF roFer a commission thatamounted to 2; of the amount he paid
%wo weeFs later (oe sold the stocF. $ereare the details of the sale
%he numer of shares that (oe sold was 1,+++
$e sold the stocF for .@2 er share
8/11/2019 Chapter 02 Programming Challenges
19/21
Develop a program that calculates theamount of prot that (oe made afterselling his stocF and paying the two
commissions to his roFer. -If the amountof prot that your program delivers is anegative numer, then (oe lost money onthe transaction/
8/11/2019 Chapter 02 Programming Challenges
20/21
1
8/11/2019 Chapter 02 Programming Challenges
21/21
%here once was a person named NAMEwho lived in CITY. &t the age of AGE,NAMEwent to college at COLLEGE.NAME
graduated and went to worF as aPROFESSION. %hen, NAMEadopted a-n/ANIMALnamed PETNAME. %hey othlived happily ever afterK