Solution - The required modified code in C++ is given below -
|
#include <bits/stdc++.h> int main(int argc, char* argv[]){ |
Explanation -
Refer to the screenshot below for code and output -
![#include <bits/stdC++.h> using namespace std; int main(int argc, char* argv[]) { string inputName; int age; bool flag = true;](http://img.homeworklib.com/questions/2ff97570-2edd-11eb-ab6f-e5ff18aa6ba9.png?x-oss-process=image/resize,w_560)
In C++ Please The given program reads a list of single-word first names and ages (ending...
6.6 LAB: Exception handling to detect input String vs. IntegerThe given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a String rather than an Integer. At FIXME in the code, add a try/catch statement to catch java.util.InputMismatchException, and output 0 for the age.Ex: If the input is:Lee 18 Lua 21 Mary Beth 19 Stu 33 -1then the output...
Write a program that reads a list of integers ending with a negative, and that then outputs that list in reverse. After the negative that ends the list, a character indicates what character should separate the output integers. If the input is: 3 5 2 - 1 * the output is: 2*5*3 LAB ACTIVITY 7.16.1: LAB: Reverse a list, with separating characters 2 / 10 main.cpp Load default template... 6 7 8 int numbers [100],i=0, num, size; char character; cin>>num;...
Write a program that Reads a string from cin Prints the first and last letter without space in between, followed by endl For example, For an input seattle your program prints se(endl). For an input newyork your program prints nk (endl). You can assume that the length of the string is always greater than 1. LAB 0/10 ACTIVITY 1.9.1: Week2-4 Zip main.cpp Load default template. #include <iostream> using namespace std; 4int mainO 6 /* 8return Type your code here. /...
In C++ please.
7.26 LAB: Nutritional information (classes/constructors) Given main(), complete the Food Item class (in files Foodltem.h and Fooditem.cpp) with constructors to initialize each food item. The default constructor should initialize the name to "None" and all other fields to 0.0. The second constructor should have four parameters (food name, grams of fat, grams of carbohydrates, and grams of protein) and should assign each private field with the appropriate parameter value. Ex: If the input is: M&M's 10.0 34.0...
First create the two text file given below. Then complete the
main that is given. There are comments to help you. An output is
also given You can assume that the file has numbers in it
Create this text file: data.txt (remember blank line at end)
Mickey 90
Minnie 85
Goofy 70
Pluto 75
Daisy 63
Donald 80
Create this text file: data0.txt (remember blank line at
end)
PeterPan 18
Wendy 32
Michael 28
John 21
Nana 12
Main
#include...
C++
how can I fix these errors
this is my code
main.cpp
#include "SpecialArray.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int measureElementsPerLine(ifstream& inFile) {
// Add your code here.
string line;
getline(inFile, line);
int sp = 0;
for (int i = 0; i < line.size(); i++)
{
if (line[i] == ' ')
sp++;
}
sp++;
return sp;
}
int measureLines(ifstream& inFile) {
// Add your code here.
string line;
int n = 0;
while (!inFile.eof())
{
getline(inFile,...
LW: Class Constructors Objectives Write a default constructor for a class. Note that this constructor is used to build the object anytime an argument is not provided when it is defined. Write a parameterized constructor that takes arguments that are used to initialize the class’s member variables Labwork Download the code associated with this lab: ColorConstructor.zip Main.cpp Color.h Color.cpp Compile and run the code. The first line of output of the program should display nonsensical integers for the values of...
Solve in C++ for Team.h and Team.cpp
Given main(). define the Team class (in files Team.h and Team.cpp). For class member function GetWinPercentage, the formula is: teamwins / (teamins + teamLosses) Note: Use casting to prevent integer division Ex: If the input is Ravens 13 3 where Ravens is the team's name, 13 is number of team wins, and 3 is the number of team losses, the output is: Congratulations, Team Ravens has a winning average! If the input is...
using C++ language!! please help me out with
this homework
In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...
in c++ please include all of the following " template class, template function, singly linked list, the ADT stack, copy constructor, operator overloading, "try catch"and pointers Modify the code named "Stack using a Singly Linked List" to make the ADT Stack that is a template class has the code of the destructor in which each node is directly deleted without using any member function. As each node is deleted, the destructor displays the address of the node that is being...