0% found this document useful (0 votes)
23 views6 pages

NCP2210 MP1

Uploaded by

Josh Cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

NCP2210 MP1

Uploaded by

Josh Cruz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

NCP 2210 (Computer Fundamentals and Programming)

MACHINE PROBLEM #1
JAVA FUNDAMENTALS
NAME: DR. JOAN P. LAZARO
SECTION: DATE: GRADE:

Problem #1
Write a program that displays the following information, each on a separate line:
 Your name
 Your address, with city, state, and ZIP
 Your telephone number and
 Your college major.
Although these items should be displayed on separate output lines, use only a single
println statement in your program.

Problem #2
Write a program that will ask the user to enter the amount of a purchase. The program
should then compute the state and county sales tax. Assume the state sales tax is 4% and
the county sales tax is 2%. The program should display the amount of the purchase, the
state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is
the sum of the amount of purchase plus the total sales tax).
Input: purchase
Output: purchase, statetax, countrytax, totaltax, totalsale
Process: statetax = purchase * 0.04; countrytax = purchase * 0.02; totaltax = statetax +
countrytax; totalsale = purchase + totaltax

1|Page
NCP 2210 (Computer Fundamentals and Programming)

Problem #3
A car’s miles-per-gallon (MPG) can be calculated with the following formula:
MPG = Miles driven / Gallons of gas used
Write a program that asks the user for the number of miles driven and the gallons of gas
used. It should calculate the car’s miles-per-gallon and display the result on the screen.
Input: milesdriven, gallonsgas
Output: MPG
Process: MPG = milesdriven / gallonsgas

Problem #4
Write a program that asks the user to enter three test scores. The program should display
each test score, as well as the average of the scores.
Input: score1, score2, score3
Output: score1, score2, score3, average
Process: average = (score1 + score2 + score3) / 3

2|Page
NCP 2210 (Computer Fundamentals and Programming)

Problem #5
An electronics company sells circuit boards at a 40 percent profit. If you know the retail
price of a circuit board, you can calculate its profit with the following formula:
Profit = Retail price × 0.4
Write a program that asks the user for the retail price of a circuit board, calculates the
amount of profit earned for that product, and displays the results on the screen.
Input: retailprice
Output: profit
Process: profit = retailprice * 0.4

Problem #6
Write a program that computes the tax and tip on a restaurant bill. The program should
ask the user to enter the charge for the meal. The tax should be 6.75% of the meal charge.
The tip should be 5% of the total after adding the tax. Display the meal charge, tax
amount, tip amount, and total bill on the screen.
Input: charge
Output: charge, tax, tip, totalbill
Process: tax = charge * 0.0675; totalbill = charge + tax; tip = totalbill * 0.05

3|Page
NCP 2210 (Computer Fundamentals and Programming)

Problem #7
Write a program that asks the user for the number of males and the number of females
registered in a class. The program should display the percentage of males and females in
the class.
Input: male, female
Output: maleper, femaleper
Process: maleper = (male / total) * 100; femaleper = (female / total) * 100

Problem #8
Diana bought a number of shares of stock at a price of P21.77 per share. She must pay
her stockbroker a 2 percent commission for the transaction. Write a program that input
the number of shares Diana bought then calculates and displays the following:
 The amount paid for the stock alone (without the commission)
 The amount of the commission
 The total amount paid (for the stock plus the commission)
Input: share
Output: amountpaid, amountcom, totalamount
Process: amountpaid = share * 21.77; amountcom = amountpaid *0.02; totalamount =
amountpaid + amountcom

4|Page
NCP 2210 (Computer Fundamentals and Programming)

Problem #9
A cookie recipe calls for the following ingredients:
 1.5 cups of sugar
 1 cup of butter
 2.75 cups of flour
The recipe produces 48 cookies with these amounts of the ingredients. Write a program
that asks the user how many cookies he or she wants to make, and then displays the
number of cups of each ingredient needed for the specified number of cookies.
Input: numcookies
Output: numsugar, numbutter, numflour
Process: numsugar = (numcookies / 48) * 1.5; numbutter = (numcookies / 48) * 1;
numflour = (numcookies / 48) * 2.75

Problem #10
Last month Jerrick purchased some stock in Degala Software, Inc. Here are the details of
the purchase:
 When Jerrick purchased the stock, he paid $32.87 per share.
 Jerrick paid his stockbroker a commission that amounted to 2% of the amount
he paid for the stock.
Two weeks later Jerrick sold the stock. Here are the details of the sale:

5|Page
NCP 2210 (Computer Fundamentals and Programming)

 He sold the stock for $33.92 per share.


 He paid his stockbroker another commission that amounted to 2% of the
amount he received for the stock.
Write a program that let the user input the number stock that was bought and sold by
Jerrick then calculate and displays the following information:
 The amount of money Jerrick paid for the stock.
 The amount of commission Jerrick paid his broker when he bought the stock.
 The amount that Jerrick sold the stock for.
 The amount of commission Jerrick paid his broker when he sold the stock.
 Display the amount of profit that Jerrick made after selling his stock and
paying the two commissions to his broker. (If the amount of profit that your
program displays is a negative number, then Jerrick lost money on the
transaction.)

6|Page

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy