• Forum
  • Blog
  • About Us
  • Privacy Policy
PC Learnings - The Gate of Knowledge
  • Home
  • PC’s & Mobiles
    • Computers
    • Laptops
    • Mobile Phones
      • Android
      • iPhone
  • Social Media
    • Facebook
    • Whatsapp
    • Twitter
    • Status And Quotes
  • Blogging & Marketing
    • Blogging Guide
    • Wordpress
    • SEO
    • Online Marketing
  • Courses
    • C Programming In Hindi/Urdu
    • C++ Programming In Hindi/Urdu
    • Problem Solutions
  • Downloads
    • Softwares
    • WordPress Plugins
No Result
View All Result
  • Home
  • PC’s & Mobiles
    • Computers
    • Laptops
    • Mobile Phones
      • Android
      • iPhone
  • Social Media
    • Facebook
    • Whatsapp
    • Twitter
    • Status And Quotes
  • Blogging & Marketing
    • Blogging Guide
    • Wordpress
    • SEO
    • Online Marketing
  • Courses
    • C Programming In Hindi/Urdu
    • C++ Programming In Hindi/Urdu
    • Problem Solutions
  • Downloads
    • Softwares
    • WordPress Plugins
No Result
View All Result
PC Learnings - The Gate of Knowledge
No Result
View All Result

Program For Ship Direction Using Class [Solved] | OOP | C++

by Syed Moin Ali
March 14, 2018
in Solutions
0
Create a class called ship that incorporates a ship’s number and location. Use the approach of Exercise 8 to number each ship object as it is created.
Use two variables of the angle class from Exercise 7 to represent the ship’s latitude and longitude.
A member function of the ship class should get a position from the user and store it in the object;
another should report the serial number and position.
Write a main()program that creates three ships, asks the user to input the position of each, and then displays each ship’s number and position…

Coding

#include<iostream>
using namespace std;
class ship{
private:
int serial;
static int num;
int degrees;
float minutes;
char direction;
public:
ship()
{
num++;
serial = num;
}
void getLoc()
{
cout << “Enter Degrees: “; cin >> degrees;
cout << “Enter Minutes: “; cin >> minutes;
cout << “Enter Direction: “; cin >> direction;
}
void reportSerLoc()
{
cout << “Ship Number ” << serial << ” Is At ” << degrees << ‘\xF8’ << minutes << “\'” << direction << endl;
}
};
int ship::num=0;

int main()
{
ship s1,s2,s3;
cout << “Enter Location Of 1st Ship” << endl;
s1.getLoc();
cout << “Enter Location Of 2nd Ship” << endl;
s2.getLoc();
cout << “Enter Location Of 3rd Ship” << endl;
s3.getLoc();
s1.reportSerLoc();
s2.reportSerLoc();
s3.reportSerLoc();
}

Output

ship class

Program For Ship Direction Using Class [Solved] | OOP | C++
5 (100%) 1 vote

ShareTweetShare

Related Posts

Programming solution to problems C++
Solutions

Checking Two Array Members Are Equal Or Not | C++

March 17, 2018
Programming solution to problems C++
Solutions

Using Array Finding Element in Index of Array | [*Solved*] | C++

March 17, 2018
Programming solution to problems C++
Solutions

Input Numbers Until -ive # Entered & Count| if Condition | C++

March 15, 2018
Programming solution to problems C++
Solutions

Print “I am object number –” | [Solved] | Classes | OOP | C++

March 14, 2018
Programming solution to problems C++
Solutions

Imagine a tollbooth at a bridge | [Solved] | Classes | OOP | C++

March 14, 2018
Next Post
Programming solution to problems C++

Input Numbers Until -ive # Entered & Count| if Condition | C++

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • edit post
    Latest Marathi Status For WhatsApp, Facebook Attitude WhatsApp Status In Marathi Cool Marathi Status Message Facebook Status In Marathi Twitter Qoutes In Marathi Marathi Sad Status For Facebook WhatsApp Marathi Love Status Marathi Status On Life

    [Latest] मराठी | Marathi Status For WhatsApp And Facebook 2018

    0 shares
    Share 0 Tweet 0
  • WhatsApp Group Names List {*2018*} | Friends, Family Lovers Funny

    36 shares
    Share 0 Tweet 0
edit post
Content Locker Pro – Premium WordPress Plugin

[Download Latest] Content Locker Pro – Free Plugin 2018

April 22, 2018
edit post
Free Download WP Smush Pro Nulled Latest Version Lifetime

[*Lifetime*] Free Download WP Smush Pro Nulled Latest Version

April 22, 2018
edit post
Render Blocking JavaScript in Wordpress

Eliminate Render Blocking JavaScript and CSS in above the fold content

April 4, 2018
edit post
leverage-browser-caching

Best Ways to Leverage Browser Caching in WordPress

April 4, 2018
PC Learnings

PC Learnings is computer learning platform established by Syed Moin Ali and team. Blog is about Blogging, Affiliate Marketing, Programming, & Computer Tips.

Categories

  • Android Phone
  • Blogging
  • Computer And Window
  • Facebook
  • iPhone
  • Laptops
  • Online Marketing
  • Programming Courses
  • SEO
  • Softwares
  • Solutions
  • Status And Quotes
  • Twitter
  • Whatsapp
  • Wordpress
  • WordPress Plugins

Newsletter

Subscribe to our mailing list and get useful stuff and updates to your email inbox

Join 1 other subscriber

  • Home
  • Register
  • About Us
  • Blog
  • Privacy Policy

Copyright © 2018 PC Learnings All Rights Reserved.

No Result
View All Result

Copyright © 2018 PC Learnings All Rights Reserved.