Concept explainers
Please help with the following C#
Please explain the following code and some of the syntax like what does like this {0} and {1}. and this {1} : {2}" What I'm most looking for is understanding what the curly braces do and the colon:
namespace CompareNames
{
class Program
{
static void Main(string[] args)
{
string name1 = "Andrew";
string name2 = "Andrew";
string name3 = "Martin";
Console.WriteLine("compare {0} to {1} : {2}", name1, name2, name1 == name2);
Console.WriteLine("compare {0} to {1} : {2}", name1, name3, name1 == name3);
Console.WriteLine();
Console.WriteLine("{0} and {1} : Equals() method gives {2}",
name1, name2, name1.Equals(name2));
Console.WriteLine("{0} and {1} : Equals() method gives {2}",
name1, name3, name1.Equals(name3));
Console.WriteLine();
Console.WriteLine("{0} and {1} : CompareTo() method gives {2}",
name1, name2, name1.CompareTo(name2));
Console.WriteLine("{0} and {1} : CompareTo() method gives {2}",
name1, name3, name1.CompareTo(name3));
Console.WriteLine();
Console.WriteLine("{0} and {1} : Compare() method gives {2}",
name1, name2, String.Compare(name1, name2));
Console.WriteLine("{0} and {1} : Compare() method gives {2}",
name1, name3, String.Compare(name1, name3));
}
}
}
Step by stepSolved in 2 steps
- FOR C++, ACCORDING THE VEHICLE HEADER, FILL THE PART 1 OF THE CODE #ifndef _Vehicle_hh_ #define _Vehicle_hh_ class Vehicle { private: float speed; float mile; public: Vehicle(); Vehicle(float, float); float getSpeed(); float getMile(); void setSpeed(float); void setMile(float); void print(); }; #endif (DEFINE FUNCTIONS CORRESPONDING TO VEHICLE HEADER CLASS IN PART 1 BELOW) #include "Vehicle.hh" #include "Ship.hh" #include <iostream> using namespace std; // *** DEFINE --VEHICLE-- FUNCTIONS FOR PART 1 *** // *** DEFINE --SHIP-- FUNCTIONS FOR PART 2 *** void reduceSpeed(Ship*, float); void takePassenger(Ship*, int); int main() { return 0; } // reduce the speed of ship given in percentage (0 < percentage < 1). void reduceSpeed(Ship *s, float percentage) { // *** FILL THIS FUNCTION FOR PART 3 *** } // takes the number of passengers to the ship void takePassenger(Ship *s, int pas) { // *** FILL THIS FUNCTION FOR…arrow_forwardC++ Help me fix my code please! I'm missing something and can't figure it out. Code and error picture are below. #include <iostream> using namespace std; class Employee{ public: string first_name; string last_name; int monthly_sal; int increment; Employee() { first_name=""; last_name=""; monthly_sal=0; increment=0; } void setFirst_Name(string first_name) { this->first_name=first_name; } void setLast_Name(string last_name) { this->last_name=last_name; } void setSal(int monthly_sal) { if(monthly_sal<0) this->monthly_sal=0; this->monthly_sal=monthly_sal; } void setInc(int increment) { monthly_sal += increment; } string getFirst_Name() { return first_name; } string getLast_Name() { return last_name; } int get_salary() { return monthly_sal; } int get_increment() { return increment;…arrow_forwardC++ enum Major {COMPUTER_SCIENCE, COMPUTER_SECURITY_INFO_ASSURANCE, CYBER_SECURITY, ELECTRICAL_ENGINEERING, OTHER}; struct Name { string first; string last; char middleInitial; }; struct StudentRecord { Name studentName; Major major; string email; }; StudentRecord student12; Suppose you are student12. Show the C++ statements used to fill in all of your information for your StudentRecord. Show how would you assign the third letter from the email field to a local char variable called myChar.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education