Question

Programming Assignment PROGRAM NEEDS TO BE DONE IN C++ A furlong is a module of distance...

Programming Assignment

PROGRAM NEEDS TO BE DONE IN C++

A furlong is a module of distance equal to 220 yards (1/8 mile). Write two classes that implement distances in the following manner:

The first class keeps track of distances as a whole number of furlongs, a whole number of yards, and a number of feet, which may have a fractional component.

The second class keeps track of distances as a whole number of kilometers, followed by a number of meters, which may have a fractional component.

Implement conversions between the two classes, ensuring that conversion in both directions is possible.

Allow the user to enter in the two types of distances and then display the conversions for each entry:

  • Furlongs, yards and feet
  • Kilometers and meters

Note that the internal view of the data is entirely up to you, but the logical view must match the specifications above. Also note that the emphasis of this assignment is on the use of conversions. Exhaustive implementations of these classes are therefore not required. The ability to declare, output, and convert constitute the essential elements. The program should still consist of at least three modules.

Submit your source code as attachments to the drop box for this module's programming assignment. You can find the drop box at the end of this module's tab page. Do not compress your attachments. Please review the requirements for submitting on the course syllabus.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Algorithm:

  • first take inputs in the selected unit system
  • then sum a total of inputs in the oposite unit system
  • then gain value of other units from total
  • print all variables .

#include<iostream>
using namespace std;
int main () {
  
//i defined a exit=0 named variable to iterate the program again and again by a while loop until exit=1 happens.
   int exit = 0 ;
   while(exit == 0) {
       cout<<"\\\\\\\\\\\\\\\\\\enter 0 to exit\\\\\\\\\\\\\\\\\\\\"<<endl;
       cout<<"\n\n1) Furlong-yeards-feet\n2) kilometer-meter\n\n\n"<<"Choose Unit System: ";
       int number_system;
       cin>>number_system;
       float furlong=0,yards=0,feet=0,km=0,m=0,total=0;
       if(number_system == 1) {
          
//taking inputs as furlongs yards and feet.
           cout<<"\n\nEnter Furlongs:\t";
           cin>>furlong;
           cout<<"Enter yards:\t";
           cin>>yards;
           cout<<"Enter feet:\t";
           cin>>feet;
          

           //summing total in meter.
           total = furlong*201 + yards*0.9144 + feet*0.3048 ;
                  
           km = (int)(total /1000);
           m = total - km*1000 ;
          
           cout<<endl<<endl;
           cout<<"Furlong: "<<furlong<<" Yard: "<<yards<<" Feet: "<<feet<<"\n\n";
           cout<<"Kilometer: "<<km<<" Meter: "<<m<<endl;
          
       }
       else if(number_system == 2){
          
//taking input as km m.
           cout<<"\n\nEnter Km:\t";
           cin>>km;
           cout<<"Enter m:\t";
           cin>>m;
          
          
//summing total in feet.
           total = km*3280.84 + m*3.28084 ;
          
           furlong = (int)(total/660.001) ;
           yards = (int)((total - furlong*660.001)/3) ;
           feet = (total - furlong*660.001 - yards*3);
      
           cout<<endl<<endl;
           cout<<"Furlong: "<<furlong<<" Yard: "<<yards<<" Feet: "<<feet<<"\n\n";
           cout<<"Kilometer: "<<km<<" Meter: "<<m<<endl;
          
       }
       else if (number_system == 0) {
           exit = 1;
       }
       else {
           cout<<"select valid option\n\n";
       }
      
   }
  
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Programming Assignment PROGRAM NEEDS TO BE DONE IN C++ A furlong is a module of distance...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the valu...

    Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...

  • Programming Assignment 6 Write a Java program that will implement a simple appointment book. The ...

    Programming Assignment 6 Write a Java program that will implement a simple appointment book. The program should have three classes: a Date class, an AppointmentBook class, and a Driver class. • You will use the Date class that is provided on Blackboard (provided in New Date Class example). • The AppointmentBook class should have the following: o A field for descriptions for the appointments (i.e. Doctor, Hair, etc.). This field should be an array of String objects. o A field...

  • Write java program The purpose of this assignment is to practice OOP with Array and Arraylist,...

    Write java program The purpose of this assignment is to practice OOP with Array and Arraylist, Class design, Interfaces and Polymorphism. Create a NetBeans project named HW3_Yourld. Develop classes for the required solutions. Important: Apply good programming practices Use meaningful variable and constant names. Provide comment describing your program purpose and major steps of your solution. Show your name, university id and section number as a comment at the start of each class. Submit to Moodle a compressed folder of...

  • ELEN 1301 Programming Assignment #5. Purpose of the program : Calculating class grade percentage. Section 1...

    ELEN 1301 Programming Assignment #5. Purpose of the program : Calculating class grade percentage. Section 1 : Enter the number of classes you attended (0 ~ 12) 5%. Section 2 : Enter the discussion board score you earned (0 ~ 120) 5%. Section 3 : Enter the quiz score you earned (0 ~ 240) 10%. Section 4 : Enter the programming assignment score you earned (0 ~ 120) 20%. Section 5 : Enter the midterm exam score you earned (0...

  • LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT...

    LAB 7-Movie List Program Goali Your assignment is to write a C++program to implement the ADT List by creating a list of movies. This assignment will help you practice: multiple file programming, classes, pablic and private methods, dynamie memory, constructors and destructors, arrays and files Implementation the required classes This lab assignment gives you the opportunity to practice creating classes and using dynamic memory in one of There are two classes to implement: Movie and MovieList. As you can see...

  • Objective: To implement the programming languages features discussed in class and to develop a program that...

    Objective: To implement the programming languages features discussed in class and to develop a program that uses Graphical User Interfaces (GUI) that provides a friendly environment for users. Project Assignment Design and implement a Hotel Reservation System. The hotel has two types of rooms. One is regular room that has two beds. Another is deluxe room that has two beds and a safe. The regular room price is $120 per night. The deluxe room is $130 per night. A safe...

  • CMSC 256 – Project 5 Programming Assignment 5 Note: When you turn in an assignment to...

    CMSC 256 – Project 5 Programming Assignment 5 Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from the instructor or teaching assistants). Program: Ticketing System Points: 100 A set of classes is used to handle the different ticket types for a theater event. All tickets have a unique serial number that is assigned...

  • Language: C# In this assignment we are going to convert weight and height. So, the user...

    Language: C# In this assignment we are going to convert weight and height. So, the user will have the ability to convert either weight or height and as many times as they want. There conversions will only be one way. By that I mean that you will only convert Pounds to Kilograms and Feet and Inches to Centimeters. NOT the other direction (i.e. to Pounds). There will be 3 options that do the conversion, one for each type of loop....

  • Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from...

    Programming Assignment #2 (Arrays) I. The Assignment This assignment is to take your Garage class from the previous assignment and modify it so that it uses an array of Car objects as the principal data structure instead of an ArrayList-of-Car. This is an example of the OOP principle of information hiding as your Car and test classes will not have to be modified at all. Unless you broke encapsulationon the previous assignment, that is   II. Specifications Specifications for all 3...

  • Hello, please solve this problem for object oriented programming in C++ program language. I have final...

    Hello, please solve this problem for object oriented programming in C++ program language. I have final tomorrow so it will be very helpful. thank you. PROBLEM 1: application that simulates the highway Create an In order to solve above mentioned requirements, it is necessary to implement several classes: 1. Class Vehicle contains information about the vehicles that drive on the highway. Each vehicle has information about its a Type (can be one of these: Motorcycle, Car, Truck) b. License number...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT