COP3813_Assignment3
2 Pages

COP3813_Assignment3

Course: CSE COP3813, Spring 2010

School: FAU

Word Count: 773

Rating:

Document Preview

COP3813 Assignment #3 Dr. Georgiana Hamza-Lup Assignment #3 - due February 19, at 11:59 pm Your assignment is to write a JavaScript program that converts specific units for length, weight, and volume from the metric system to the US system and from the US system to the metric system. Before asking the user for the value to be converted, the program should prompt the user to select the type of conversion: 1....

Unformatted Document Excerpt
Coursehero >> Florida >> FAU >> CSE COP3813

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

#3 Dr. COP3813 Assignment Georgiana Hamza-Lup Assignment #3 - due February 19, at 11:59 pm Your assignment is to write a JavaScript program that converts specific units for length, weight, and volume from the metric system to the US system and from the US system to the metric system. Before asking the user for the value to be converted, the program should prompt the user to select the type of conversion: 1. Length (feet meters: there are 3.2808 feet in a meter) a. Ask if the conversion is from feet to meters b. Or from meters to feet 2. Weight (pound kilograms: there are 2.2046 pounds in a kilogram) a. Ask if the conversion is from pounds to kilograms b. Or from kilograms to pounds 3. Volume (gallons liters: there are 3.7854 litters in a gallon) a. Ask if the conversion is from gallons to liters b. Or from liters to gallons The program should output the original value and the converted value in the correct units. Then it should prompt the user for another calculation. If the response is Y or y the program will be repeated. A response of N or n will cause the program to exit. Any other response will re-display the prompt. The program must consist of a minimum of 4 user defined functions. Embed the script in an html file, name that file hw3.html and upload it in your public_html directory on lamp. Make sure to set proper permissions for that file (e.g., chmod 644 hw3.html) and verify that it is accessible by going to: http://lamp.cse.fau.edu/~your-username/hw3.html Nothing needs to be submitted through Blackboard. Here is the C++ code for this program (you need to translate it into JavaScript). #include <iostream> #include <string> using namespace std; void conversion(); //prompts the user for the original_units and new_units through a set of menus //then it prompts the user for the value to be converted & performs the conversion int choose_direction(string option1, string option2); //Precondition: option1 and option2 have been initialized to two string representing the user options //Poscondition: returns the user selection: 1 if the option1 is selected and 2 if option2 is selected 1 COP3813 Assignment #3 Dr. Georgiana Hamza-Lup double pounds_kilograms(double value, int direction); //Precondition: value has been initialized and direction has been initialized to either 1 or 2 //Postcondition: returns the result of converting value from pounds to kilograms if direction is 1, and from kilograms to pounds if direction is 2 double gallons_litters(double value, int direction); //Precondition: value has been initialized and direction has been initialized to either 1 or 2 //Postcondition: returns the result of converting value from gallons to litters if direction is 1,and from litters to gallons if direction is 2; double feet_meters(double value, int direction); //Precondition: value has been initialized and direction has been initialized to either 1 or 2 //Postcondition: returns result the of converting value from feet to meters if direction is 1, and from meters to feet if direction is 2 int main() { char repeat; cout << "Unit converter" << endl << endl; do { conversion(); //promt user for another calculation do { cout << "\nDo you want to perform another conversion (enter 'Y' or 'N'): "; cin >> repeat; } while ((repeat != 'y')&&(repeat != 'Y')&&(repeat != 'n')&&(repeat != 'N')); cout << endl; } while ((repeat == 'y') || (repeat == 'Y')); } void conversion() { int unit, direction; double value, result; string original_units, new_units; cout << "1. Convert lenght" << endl; cout << "2. Convert weight" << endl; cout << "3. Convert volume" << endl; do { cout << "Select conversion type: "; cin >> unit; } while ((unit<0)||(unit>3)); switch(unit) { case 1: direction = choose_direction("1. Feet to meters", "2. Meters to feet"); if (direction == 1) {original_units = " feet"; new_units = " meters";} else {new_units = " feet"; original_units = " meters";} break; case 2: direction = choose_direction("1. Pounds to kilograms", "2. Kilograms to pounds"); if (direction == 1) {original_units = " pounds"; new_units = " kilograms";} 2 COP3813 Assignment #3 Dr. Georgiana Hamza-Lup else {new_units = " pounds"; original_units = " kilograms";} break; case 3: direction = choose_direction("1. Gallons to litters", "2. Litters to gallons"); if (direction == 1) {original_units = " gallons"; new_units = " litters";} else {new_units = " gallons"; original_units = " litters";} break; } cout << "Enter value to be converted: "; cin >> value; switch(unit) { case 1: result = feet_meters(value, direction); break; case 2: result = pounds_kilograms(value, direction); break; case 3: result = gallons_litters(value, direction); break; } cout << value << original_units << " = " << result << new_units << endl; } int choose_direction(string option1, string option2) { int direction; cout << endl; cout << option1 << endl; cout << option2 << endl; do { cout << "Select a conversion direction: "; cin >> direction; } while ((direction!=1)&&(direction!=2)); return direction; } double pounds_kilograms(double value, int direction) { if (direction == 1) return value/2.2046; else return value*2.2046; } double gallons_litters(double value, int direction) { if (direction == 1) return value*3.7854; else return value/3.7854; } double feet_meters(double value, int direction) { if (direction == 1) return value/3.2808; else return value*3.2808; } 3

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Southern Methodist - FAM - 1111
Family Law OutlineFall 2006 Chapter 1: American Family Law: Definitions, Policy and Trends Section 1: The New Family and The New Family Law The New FamilyMary Ann Glendon Three important attributes of the modern family Fluidity Detachability Interchangeab
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 5: The Structure and Function of MacromoleculesChapter Questions1) Which of the following is not one of the four major groups of macromolecules found in living organisms? A) glucose B) carbohydrates C) lipids D) proteins E
University of Florida - PHYSICS - phy2043
Chapter 5, EnergyCHAPTER 55.1 Work 1. The unit of work, joule, is dimensionally the same as: a. newton/second. b. newton/kilogram. c. newton-second. d. newton-meter. 2. Rupel pushes a box 5.00 m by applying a 25.0-N horizontal force. What work does she
University of Florida - PHYSICS - phy2043
Chapter 6, Momentum and CollisionsCHAPTER 66.1 Momentum and Impulse 1. A valid unit for momentum is which of the following? a. kgm/s2 b. kg/m2 c. kgm/s d. Nm 2. The dimensional equivalent of the quantity impulse in terms of the fundamental quantities (m
University of Florida - PHYSICS - phy2043
Chapter 7, Rotational Motion and the Law of GravityCHAPTER 77.1 Angular Speed and Angular Acceleration 1. 2 600 rev/min is equivalent to which of the following? a. 2600 rad/s b. 43.3 rad/s c. 273 rad/s d. 60 rad/s 2. A grindstone spinning at the rate of
University of Florida - PHYSICS - phy2043
Chapter 8, Rotational Equilibrium and Rotational DynamicsCHAPTER 88.1 Torque 1. A vault is opened by applying a force of 300 N perpendicular to the plane of the door, 0.80 m from the hinges. Find the torque due to this force about an axis through the hi
University of Florida - PHYSICS - phy2043
Chapter 9, Solids and FluidsCHAPTER 99.1 States of Matter 9.2 The Deformation of Solids 1. Which state of matter is associated with the very highest of temperatures? a. liquid b. plasma c. gas d. solid 2. A copper wire of length 2.0 m, cross sectional a
University of Florida - PHYSICS - phy2043
Chapter 10, Thermal PhysicsCHAPTER 1010.1 Temperature and the Zeroth Law of Thermodynamics 10.2 Thermometers and Temperature Scales 1. Which best describes the relationship between two systems in thermal equilibrium? a. no net energy is exchanged b. vol
University of Florida - PHYSICS - phy2043
Chapter 11, Energy in Thermal ProcessesCHAPTER 1111.1 Heat and Internal Energy 11.2 Specific Heat 1. Arrange from smallest to largest: the BTU, the joule, and the calorie. a. BTU, J, cal b. J, cal, BTU c. cal, BTU, J d. J, BTU, cal 2. Of the following s
University of Florida - PHYSICS - phy2043
Chapter 12, The Laws of ThermodynamicsCHAPTER 1212.1 Work in Thermodynamic Processes 1. The volume of an ideal gas changes from 0.40 to 0.55 m3 although its pressure remains constant at 50 000 Pa. What work is done on the system by its environment? a. 7
University of Florida - PHYSICS - phy2043
Chapter 14, SoundCHAPTER 1414.1 Producing a Sound Wave 1. When a sine wave is used to represent a sound wave, the crest corresponds to: a. rarefaction. b. condensation. c. point where molecules vibrate at a right angle to the direction of wave travel. d
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 4: Carbon and the Molecular Diversity of LifeChapter Questions1) Organic chemistry is a science based on the study of A) functional groups. B) vital forces interacting with matter. C) carbon compounds. D) water and its int
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 8: An Introduction to MetabolismChapter Questions1) Which of the following describe(s) some aspect of metabolism? A) synthesis of macromolecules B) breakdown of macromolecules C) control of enzyme activity D) A and B only
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 10: PhotosynthesisChapter Questions1) Organisms that can exist with light as an energy source and an inorganic form of carbon and other raw materials A) are called photoautotrophs. B) do not exist in nature. C) are called
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 17: From Gene to ProteinChapter Questions1) Garrod hypothesized that &quot;inborn errors of metabolism&quot; such as alkaptonuria occur because A) genes dictate the production of specific enzymes, and affected individuals have genet
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 22: Descent with Modification: A Daarwinian View of LifeChapter Questions1) On which of the following did Linnaeus base his classification system? A) morphology and anatomy B) evolutionary history C) the fossil record D) A
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 23: The Evolution of PopulationsChapter Questions1) What is the most important missing evidence or observation in Darwin's theory of 1859? A) the source of genetic variation B) evidence of the overproduction of offspring C
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 46: Animal ReproductionChapter Questions1) What do budding and fragmentation have in common? A) Both are types of asexual reproduction. B) Both produce large numbers of offspring. C) Both occur in sea stars. D) Both involv
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 55: Conservation Biology and Restoration EcologyChapter Questions1) What is the estimated number of extant species on Earth? A) 1,000 to 50,000 B) 50,000 to 150,000 C) 500,000 to 1,000,000 D) 10,000,000 to 200,000,000 E) 5
University of Florida - BIO - BSC2011
Biology, 7e (Campbell)Chapter 32: An Introduction to Animal DiversityChapter Questions1) Most animals exhibit the following structures or functions except A) nervous and muscle tissue. B) unique types of intercellular junctions, such as tight junctions
東京国際大学 - SCI - 101
TCM DiagnosisPattern identification through 8 principles, Zang Fu, Pathogenic Factors, and Meridians Chills and fever (feeling of heat) - Alternating chills and fever (exterior invasion of wind/cold or wind/heat at ShaoYang stage) - Aversion to cold (win
DeVry Chicago - ENG227 - ENG227
Process-Oriented Writing &amp; Formatting Business Messages TCOs 1, 2, 12 1 Audience analysis, persuasionChapter 1: Achieving Success Through Effective Business Communication Chapter 4: Planning Business Messages Given the task of selling a product or servic
Punjab Engineering College - ENGR - 1828839231
FACULTY OF ENGINEERING AND APPLIED SCIENCEENGR3930U-Heat Transfer Assignment #2Instructors: TA: Dr. Anand S. Joshi and Dr. Calin Zamfirescu Kevin PopeDrop Box: 11 (or submitted to the TA during tutorial or office hours) Due: February 23, 2010 - 7:30pm
Bryant - ECO - 114
Chapters6&amp;7GDP Growth InstabilityTheMacroEconomy Aggregates Consumption(consumersspending), Demand(demandforallgoods/services), Investment,Spending,Savings Output(Q),standardofliving LongTermgrowth EconomicIndicators Shortrunvariabilityrecession R
UCLA - HUMANITIES - --
Ngoc Bui English Comp.3 Sec #9 Professor Lisovsky Ishmael Ch.1-4 Questions1. Have you ever felt you were being told a great lie, as does Kurt in the narrator's parable (1.7)? Is this some kind of &quot;captivity&quot; as Ishmael expresses it? At this point of the
UCLA - ENGLISH CO - --
Ngoc Bui English Comp.3 Sec#9 Lisovsky Ishmael Ch.5-8 Q&amp;A Chapter 5 1. What new notions appear in this chapter? The idea of why mans destiny is to destroy the Earth is introduced. Mans destiny, as we have learned from Chapter 1 to Chapter 4, is to conquer
UCLA - ENGLISH CO - --
Ngoc Bui English Comp.3 Sec#9 Lisovsky Ishmael Ch.9-13 Q&amp;A Chapter 9 1. This chapter is complicated yet compelling. What are Quinn's most memorable points in this chapter? What is the lesson behind Ishmael's parable in 9.4 through 9.6? (Try not to get too
UCLA - ENGLISH CO - --
Ngoc Bui English Comp.3 Sec#9 Lisovsky Nonzero Q&amp;A 1. In &quot;The Way We Were&quot;, Wright spends a lot of time talking about cultural evolution. What is it, according to him, and why is the definition important? How does it categorically differ from Quinn's (Ish
UCLA - ENGLISH CO - --
Ngoc Bui English 3 Sec#9 Professor Lisovsky Garrett Hardin Q&amp;A 1. Somebody has just cornered you in the hallway and confided that they are certain that they'll be called upon in their next class to offer a brief synopsis of Hardin's Tragedy of the Commons
UCLA - ENGLISH CO - --
Ngoc Bui English 3 Sec#9 Professor Lisovsky Guns, Germs and Steel Questions 1. What do you think the expression &quot;guns, germs and steel&quot; in the source title refers to, now that you have read the excerpt from the book? I believe that with the title Guns, Ge
UCLA - ENGLISH CO - --
Ngoc Bui English Comp.3 Lisovsky Bodley Q&amp;A1. What is the significance of cultural scale, according to Bodley? Culture scale measures differences among cultures on various social and economic dimensions, based on different modes of organizing social powe
CSU San Bernardino - ACTG - 23123
ACC 219 Quiz #1Student: _1. The Federal Accounting Standards Advisory Board (FASAB) recommends accounting principles and standards for the federal government and its agencies and state governments. True False2. The government-wide financial statements
CSU San Bernardino - ACTG - 23123
CSU San Bernardino - ACTG - 23123
ACC 219 Quiz 3Student: _1.Which of the following activities would be most appropriately recorded by an agency fund? A. B. C. D. Deposits held for customers of a city-owned electric utility. Assets held for special assessment bondholders when the city i
CSU San Bernardino - ACTG - 23123
ACC 219 Quiz #4Student: _1.Cash received by a nongovernmental NPO in year 1 that the donor stipulates is to cover operating expenses of the following year should be recognized as an &quot;increase in temporarily restricted net assets&quot; in year 1 and as &quot;net
CSU San Bernardino - ACTG - 23123
Select the BEST answer to each question from those given. Each Problem is worth 4 points.1. The Financial Accounting Standards Board has the responsibility for setting accounting and financial reporting standards forA) All federal and state organization
CSU San Bernardino - ACTG - 23123
Select the BEST answer to each question from those given. Each Problem is worth 4 points.1. Which of the following would be considered a general capital asset?A) A vehicle purchased from general fund revenues. B) A vehicle purchased and maintained by an
CSU San Bernardino - ACTG - 23123
Select the BEST answer to each question from those given. Each Problem is worth 4 points.1. The Governmental Accounting Standards Board has the responsibility for setting accounting and financial reporting standards forA) State and local government enti
CSU San Bernardino - ACTG - 23123
Select the BEST answer to each question from those given. Each Problem is worth 4 points.1. Accountability for capital assets used by departments accounted for by the governmental funds of a government should be established inA) The appropriate governme
CSU San Bernardino - ACTG - 23123
Select the BEST answer to each question from those given. Each Problem is worth 4 points. 1. What is the objective of financial reporting by state and local governments? A) The same as the objectives of financial reporting by business enterprises. B) To r
CSU San Bernardino - ACCT - 34231
COMPREHENSIVE ANNUAL FINANCIAL REPORTFOR THE FISCAL YEAR ENDED JUNE 30, 2009City of FontanaCaliforniaMark N. Nuaimi, Mayor Acquanetta Warren, Mayor Pro Tem John B. Roberts, Council Member Janice Rutherford, Council Member Frank Scialdone, Council Memb
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
Chapter2Principles of Accounting and Financial Reporting for State and Local GovernmentsMcGrawHill/IrwinCopyright2010byTheMcGrawHillCompanies,Inc.Allrightsreserved.Learning ObjectivesAfter studying Chapter 2, you should be able to:Explain the natur
CSU San Bernardino - ACCT - 34231
Chapter6Accounting for General LongTerm Liabilities and Debt ServiceMcGrawHill/IrwinCopyright2010byTheMcGrawHillCompanies,Inc.Allrightsreserved.Learning ObjectivesAfter studying Chapter 6, you should be able to: Explain what types of liabilities are
CSU San Bernardino - ACCT - 34231
15/eAccounting for Governmental &amp; Nonprofit EntitiesEARL R. WILSON JACQUELINE L. RECK SUSAN C. KATTELUS11Chapter1Introduction to Accounting and Financial Reporting for Governmental and Not-forProfit EntitiesMcGrawHill/Irwin Copyright2010byTheMcGraw
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
Chapter3Governmental Operating Statement Operating Statement Accounts; Budgetary AccountingMcGraw-Hill/IrwinCopyright 2010 by The McGraw-Hill Companies, Inc. All rights reserved.Government-wide Statement of Activities (Cont Activities (Contd) Progra
CSU San Bernardino - ACCT - 34231
CSU San Bernardino - ACCT - 34231
1/18/2010Chapter3Governmental Operating Statement Accounts; Budgetary AccountingLearning ObjectivesAfter studying Chapter 3, you should be able to: Explain how operating expenses and revenues related to governmental activities are classified and repo
CSU San Bernardino - ACCT - 34231
Chapter5Accounting for General Capital Assets and Capital ProjectsMcGraw-Hill/IrwinCopyright 2010 by The McGraw-Hill Companies, Inc. All rights reserved.What are General Capital Assets?Long-lived assets used by activities reported in governmental fu
CSU San Bernardino - ACCT - 34231
Chapter7Accounting for the BusinessType Activities of State and Local GovernmentsProprietary FundsReasons for use Enhances management of activities in which goods or services are provided on a cost-reimbursement basis to departments of the same govern
CSU San Bernardino - ACCT - 34231
Chapter 02 - Principles of Accounting and Financial Reporting for State and Local GovernmentsCHAPTER 2:PRINCIPLES OF ACCOUNTING AND FINANCIAL REPORTING FOR STATE AND LOCAL GOVERNMENTSIN CLASS EXERCISE: 2-9. General Fund Debits Cash 1,000,000 Other Fina
CSU San Bernardino - ACCT - 34231
CHAPTER 4:ACCOUNTING FOR GOVERNMENTAL OPERATING ACTIVITIES ILLUSTRATIVE TRANSACTIONS AND FINANCIAL STATEMENTSIN CLASS EXERCISE 4-4. $6,720,000 $6,720,000 $6,720,000 gross levy = gross levy - (.04 * gross levy) = (1 - .04) * gross levy = .96 * gross levy
CSU San Bernardino - ACCT - 34231
Quiz #51. Which of the following financial statement(s) reports both current and noncurrent assets and liabilities?A. Choice A B. Choice B C. Choice C D. Choice D 2. Which of the following should not be reported as a liability of the General Fund? A. Ge
CSU San Bernardino - ACCT - 34231
CHAPTER 3: GOVERNMENTAL OPERATING STATEMENT ACCOUNTS; BUDGETARY ACCOUNTING3-1.Each student should have a different governmental annual report, so will have different answers to the questions in this exercise. Some time spent in class to allow students t
CSU San Bernardino - ACCT - 34231
Accounting 468 CAFR PROJECT Due: Worth 100 points Purpose of this assignment : T he objective of this assignment is for you to learn how to read a governments financial statements and understand what those numbers mean. You will complete a financial analy
CSU San Bernardino - ACCT - 34231
CSUSB ACCOUNTING 468 ACCOUNTING FOR GOVERNMENTS AND NON-PROFIT ORGANIZATIONS HOMEWORK 3-1 Examine the CAFR. UtilizingtheCAFRobtainedforHomework11,reviewthegovernmentalfundfinancial statementsandrelateddataandgovernmentwidefinancialstatements.Noteparticula