string txt = "Noor"; cout 1: . "The ;. .length of the txt string is: " << 2 txt.string(); txt.length(); IIII. txt+"; くく append(); << , txt[4]; >>
Q: Dec2Hex function : def decimal_to_hex(number): hex_map = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5:…
A: The question asks you to perform the following tasks: Profile the decimal_to_hex function: Measure…
Q: iostream> using namespace std; string name; int number; int age; string city;
A: It is defined as a direct descendant of C programming language with additional features such as type…
Q: #include #include #include using namespace std; struct Student{ string firstName; string…
A: 1st error: You close the class before the gpacalculation function so that’s why code shows the…
Q: #include #include #include #include #include using namespace std; class StudentRec { private:…
A: #include<iostream>#include<iomanip>#include<string>#include<vector>#include&…
Q: #include using namespace std; int main() { string c_name ; string car_n; int n, member_n ,…
A: In your program code after input the service number from the user, you need to assign the charges…
Q: #include #include #include using namespace std; struct Player { string firstName;…
A: #include <iostream>#include <vector>#include <algorithm> using namespace std;…
Q: using System; using System.Linq; using System.Text; namespace Games; { class Program { staticvoid…
A: GIVEN: using System; using System.Linq; using System.Text; namespace Games; { class Program {…
Q: main.cc file
A: Cup Class Definition (cup.h):Define a class named Cup.Declare private member variables: drink_type_…
Q: Alternate Character DisplayWrite a method that accepts a String object as an argument and then…
A: Here is Your Code
Q: Palindrome Checker create a JavaScript program that checks if phrases entered by the user are…
A: In this question we have to write a JavaScript code for the plaindrome check Let's code and hope…
Q: bool vall=2; double val12=3; int val3='B'; val3+=pow (val2++, val1);…
A: The above code gives an error because, the variable val3 is of integer type and it is assigned to a…
Q: 6.12 LAB: Parsing dates Complete main() to read dates from input, one date per line. Each date's…
A: Initialize a map called "months" that associates the names of months with their corresponding…
Q: main.cc file #include #include #include #include "cup.h" int main() {…
A: C++ which refers to the one it is a general-purpose programming language. It is a cross-platform…
Q: Implementing the Customer Class We've partially defined the Customer class for you in "customer.h"…
A: Create a Customer class with member variables for the name of the customer, the number of products…
Q: #include #include "ContactNode.h" int main() { ContactNode* contactList = new ContactNode();…
A: The source code of the program #main.cpp #include <iostream>#include "ContactNode.h"int…
Q: clude #include #include "cup.h" int main() { std::string drink_name; double amount = 0.0;…
A: The code you provided seems to be incomplete, as there are placeholders for you to write your own…
Q: Fix this code please #include #include #include #include Using namespace std; //Structure…
A: C++ Code: #include <iostream>#include <iomanip>#include <fstream>#include…
Q: Assume that int a[ 2 ][ 2 ] = { { 1, 2 }, { 3, 4 } }; the value of a[ 1, 1 ] = ______;
A: #include<stdio.h> int main(){ int i=0,j=0; int arr[2][2]={{1,2},{3,4}};…
Q: xplain Structures and how this code works: - Imagine you're teaching the material to someone who…
A: Java is one of the languages, which is considerably used in many sectors of Computer. In older…
Q: remove_substring_from_string(s, substr): This function takes two strings s and substr as input. It…
A: PROGRAM CODE: # start definition of function to remove substringdef remove_substring_from_string(s,…
Q: main.cc file #include #include #include #include "cup.h" int main() { std::string…
A: C++ is an extension of the C programming language, with additional features such as classes,…
Q: In this lab, you complete a partially wri Cornwall's Country Inn. The program is described in…
A: Check the answer as well as meal plan whether they are valid or not In case of invalid strings…
Q: Employee's first name: Kim Employee's last name: Smith Number of shifts: 25 Number of transactions:…
A: #include<iostream> #include<string> using namespace std; int main(){ // Declare and…
Q: main.cc file #include #include #include #include "cup.h" int main() { std::string…
A: C++ is a popular programming language. C++ is a cross-platform language that can be used to create…
Q: Write a short program that asks the user to supply some text and then provides the number of 'e's in…
A: To write java program to display number of 'e' in the given text from user.
Q: void showLinked() Linked_List "p; p=List; while(pl-NULL) coutname agephoneNOID_NOnext; } cout>k;…
A: #include <bits/stdc++.h> using namespace std; class Node { public: int data; Node *next;…
Q: The program should ask for the data to fill a studentRec of structure StudentRec and then ask y/n if…
A: Instruction we need to follow: The program should ask for the data to fill a studentRec of structure…
Q: #include #include #include #include #include #include "CommonName.h" #include "Name.h"…
A: Introduction C++ Class: The fundamental unit of Object-Oriented programming in C++ is a class. It's…
Q: // Airline.cpp - This program determines if an airline passenger is // eligible for a 25% discount.…
A: Note: I HAVE GIVEN THE SOLUTION AS PER THE OUTPUT GIVEN IN THE QUESTION. Define header file…
Q: mployees of a supermarket. The report lists total hours for // each day of one week. // Input:…
A: code : #include <iostream> #include <string> using namespace std; //main function…
Q: Please provide proper comments. Define the following code. #include 2 #include 3 4 #define…
A: This is the C language code which is playing some songs and calculating their playing time in…
Q: #include #include using namespace std; int index1(char *T,char *P) { int t=0,p=0,i,j,r;…
A: To remove function, use all statements outside the function and remove the function header. instead…
Q: function called 2) Define and call a value-returning hideNumbers. The function accepts a string as…
A: 1. Accept a string of digits as the input parameter. 2. Check if the length of the input…
Q: #include using namespace std; int main() { string name,address,c_qual,c_spec,c_status; int…
A: As I go through the code I found you didn't check that entered value is an integer or not. so you…
Q: Homework 10-1 Programming Challenge: 2 - Backwards String Write a function that accepts a string…
A: Solution: Given, Write a function that accepts a string and returns a string in which the…
Q: 2.20 LAB: Hypotenuse Given two numbers that represent the lengths of a right triangle's legs (sides…
A: Introduction: The name "Hypotenuse" in mathematics derives from the Greek word hypoteinousa, which…
Q: // Cornwall.cpp - This program computes hotel guest rates.// Input: None// Output: Hotel guest…
A: Actually, c++ is a powerful general purpose language. It is a high level language.
Q: Please fix my code, my error is the bold part This is a program that inputs, processes, and…
A: Introduction: The program ask for the data to fill a studentRec of class StudentRec and then ask…
Q: #include #include #include using namespace std; // structure struct Hat { string size; string…
A: Programming---- In very simple terms programming is a way to instruct the computer devices to…
Q: Flowchart, create. #include #include using namespace std; double computeRate(int); double…
A: Here our ask is to draw a flow chart to the given program. First, let's understand the program a…
Q: #include #include #include using namespace std; class BalancedTernary { protected: //…
A: Output of the given code: In the main function, the code asks for input of a,b,c and calls…
Step by step
Solved in 2 steps with 1 images
- // ChangeCase.cpp - This program converts characters to lowercase and uppercase.// Input: Interactive// Output: Uppercase and lowercase versions of the user-entered string#include <iostream>#include <string>using namespace std;int main() { const int LEN = 9; char sample1[LEN]; char sample2[LEN]; char result1; char result2; int i; cout << "Enter 9 lowercase characters: "; for(i = 0; i < LEN; i++) { cin >> sample1[i]; // Convert sample1[i] to uppercase and assign it to result1 cout << result1 << endl; } cin.ignore(256,'\n'); cout << "Enter 9 uppercase characters: "; for(i = 0; i < LEN; i++) { cin >> sample2[i]; // Convert sample2[i] to lowercase and assign it to result2 cout << result2 << endl; } cin.ignore(256,'\n'); return 0;} // End of main() function#include <iostream>#include <string.h>using namespace std;int index1(char *T,char *P){int t=0,p=0,i,j,r;t = strlen(T);p = strlen(P);i=0;int max = t - p + 1;while(i<max){for(j=0;j<p;j++){if(P[j]==T[i+j]){r = i;break;}else r = -1;}i++;}return r;} int main(){ int l;char c[100];char d[100];cout<<"Enter First String\n"; cin>>c;cout<<"Enter Second String\n";cin>>d;l = index1(c,d);cout<<l; return 0;} Note: Remove Funcation// P41.cpp - A simple elevator for 4 floors and a basement with a // close door button and 5 keys for floors #include<iostream> #include<cmath> using namespace std; void close_door(); int change_floor(int choice, int floor); int main( ) { int key; int floor = 0; cout << "Press a Key \n"; cin >> key; if(key == 0) { close_door(); if( floor != 0){ // otherwise nothing happens cout << "I am moving to the Basement \n"; floor = change_floor(0, floor); } } else if(key == 1) { close_door(); if( floor != 1){ // otherwise nothing happens cout << "I am moving to the the First Floor \n"; floor = change_floor(1, floor); } } else if(key == 2) { close_door(); if( floor != 2){ // otherwise nothing happens cout << "I am moving to the the Second Floor \n"; floor = change_floor(2, floor); } } else if(key == 3) { close_door(); if( floor != 3){ // otherwise nothing happens cout << "I am moving to the the Third Floor \n"; floor = change_floor(3, floor); } }…
- main.cpp: #include <iostream>#include <iomanip>#include "Calculator.h"using namespace std; int main() {Calculator calc; double num1; double num2; cin >> num1; cin >> num2; cout << fixed << setprecision(1); // 1. The initial value cout << calc.GetValue() << endl; // 2. The value after adding num1 calc.Add(num1); cout << calc.GetValue() << endl; // 3. The value after multiplying by 3 calc.Multiply(3); cout << calc.GetValue() << endl; // 4. The value after subtracting num2 calc.Subtract(num2); cout << calc.GetValue() << endl; // 5. The value after dividing by 2 calc.Divide(2); cout << calc.GetValue() << endl; // 6. The value after calling the clear() method calc.Clear(); cout << calc.GetValue() << endl; return 0;} Calculator.h: #ifndef CALCULATORH#define CALCULATORH class Calculator { public: //…Explain the code and how it works: #include <iostream>#include <iomanip>#include <string>#include <vector>#include <cmath> using namespace std; struct PlayerRec{ string first_name = ""; //First Name string last_name = " "; //Last Name int game = 0; // number of games played float points = 0.0; // points per game of the player}; int main(){ float avgppg = 0; cout << "The Basketball Player List Program\n\n"; cout << "Enter a Player Record \n\n"; // Get vector of PlayerRec objects vector<PlayerRec> player_list; char another = 'y'; while (tolower(another) == 'y') { PlayerRec PlayerRec; // make temporary new (initialized) PlayerRec object cout << "First Name: "; getline(cin, PlayerRec.first_name); cout << "Last name: "; getline(cin, PlayerRec.last_name); cout << "Games Played: "; cin >> PlayerRec.game;…main.cc file #include <iostream>#include <memory> #include "customer.h" int main() { // Creates a line of customers with Adele at the front. // LinkedList diagram: // Adele -> Kehlani -> Giveon -> Drake -> Ruel std::shared_ptr<Customer> ruel = std::make_shared<Customer>("Ruel", 5, nullptr); std::shared_ptr<Customer> drake = std::make_shared<Customer>("Drake", 8, ruel); std::shared_ptr<Customer> giveon = std::make_shared<Customer>("Giveon", 2, drake); std::shared_ptr<Customer> kehlani = std::make_shared<Customer>("Kehlani", 15, giveon); std::shared_ptr<Customer> adele = std::make_shared<Customer>("Adele", 4, kehlani); std::cout << "Total customers waiting: "; // =================== YOUR CODE HERE =================== // 1. Print out the total number of customers waiting // in line by invoking TotalCustomersInLine. //…
- // LeftOrRight.cpp - This program calculates the total number of left-handed and right-handed // students in a class. // Input: L for left-handed; R for right handed; X to quit. // Output: Prints the number of left-handed students and the number of right-handed students. #include <iostream> #include <string> using namespace std; int main() { string leftOrRight = ""; // L or R for one student. int rightTotal = 0; // Number of right-handed students. int leftTotal = 0; // Number of left-handed students. // This is the work done in the housekeeping() function cout << "Enter an L if you are left-handed, a R if you are right-handed or X to quit: "; cin >> leftOrRight; // This is the work done in the detailLoop() function // Write your loop here. // This is the work done in the endOfJob() function // Output number of left or right-handed students. cout << "Number of left-handed students:…in c++ i have this struct struct Student { string firstName, lastName; int pointTotal; }; void printStudent(const Student & s) { cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl;}void printAll(Student students[], int numStudents) { for (int i = 0; i < numStudents; i++) printStudent(students[i]); cout << endl;}int main() { const int NUMSTUDENTS = 7; Student students[NUMSTUDENTS] = { {"Brian", "Jones", 45},{"Edith", "Piaf", 45},{"Jacques", "Brel", 64},{"Anna", "Brel", 64}, {"Carmen", "Jones", 45} , {"Carmen", "Brel", 64}, {"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} }; printAll(students, NUMSTUDENTS); sortByPointTotal(students, NUMSTUDENTS); printAll(students, NUMSTUDENTS); return 0;} i need to make a function that uses bubble sort(coded from scratch), but modify it so that the comparison for out-of-order elements takes into account all three fields:…//main.cpp #include "Person.h"#include "Seller.h"#include "Powerseller.h"#include <iostream>#include <list>#include <fstream>#include <string> using namespace std; void printMenu();void printSellers(list<Seller*> sellers);void checkSeller(list<Seller*> sellers);void addSeller(list<Seller*> sellers);void deleteSeller(list<Seller*> &sellers); int main() { list<Seller*> sellers; ifstream infile; infile.open("sellers.dat"); if (!infile) { cerr << "File could not be opened." << endl; exit(1); } char type; while (!infile.eof()) { infile >> type; if (type == 'S') { Seller* newseller = new Seller; newseller -> read(infile); sellers.push_back(newseller); } if (type == 'P') { Powerseller* newpowerseller = new Powerseller; newpowerseller -> read(infile); sellers.push_back(newpowerseller); } } infile.close();…
- Main.cpp #include <iostream>#include "Deck.h" int main() { Deck deck; deck.shuffle(); std::cout << "WAR Card Game\n\n"; std::cout << "Dealing cards...\n\n"; Card player1Card = deck.Deal(); Card player2Card = deck.Deal(); std::cout << "Player 1's card: "; player1Card.showCard(); std::cout << std::endl; std::cout << "Player 2's card: "; player2Card.showCard(); std::cout << std::endl; int player1Value = player1Card.getValue(); int player2Value = player2Card.getValue(); if (player1Value > player2Value) { std::cout << "Player 1 wins!" << std::endl; } else if (player1Value < player2Value) { std::cout << "Player 2 wins!" << std::endl; } else { std::cout << "It's a tie!" << std::endl; } return 0;} Card.h #ifndef CARD_H#define CARD_H class Card {public: Card(); Card(char r, char s); int getValue(); void showCard();…#include#include#includeusing namespace std;// outputHtmlTitle// parameters// This function...void outputHtmlTitle(ofstream & fout, string title){fout << "" << endl;fout << "" << endl;fout << "" << endl;fout << "" << endl;fout << title << endl;fout << "" << endl;}void outputHtmlFooter(ofstream & fout){fout << "" << endl;fout << "" << endl;}void outputHtmlList(ostream & fout, string first, string second, string third){fout << "" << endl;fout << "\t" << first << "" << endl;fout << "\t" << second << "" << endl;fout << "\t" << third << "" << endl;fout << "\t" << endl;}void main(int argc, char * *argv){ofstream htmlFile("myIntro.html");string title;cout << "Please enter the title: ";getline(cin, title);outputHtmlTitle(htmlFile, title);string name;string course1, course2, course3;cout…. Look at the following statement:mystring = 'cookies>milk>fudge>cake>ice cream'Write a statement that splits this string, creating the following list:['cookies', 'milk', 'fudge', 'cake', 'ice cream']