Simple C++: Getting an input file and doing calculations.
Input file to be read from should be named "1030Prob1.dat" it will contain the following::
John Harris 11374 50000.00 Lisa Smith 11985 75000.00 Adam Johnson 12585 68500.00 Sheila Smith 11654 150000.00 Tristen Major 11274 75800.00 Yannic Lennart 15687 58000.00 Lorena Emil 17414 43000.00 Tereza Santeri 12597 48000.00
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream inputFile;
inputFile.open("1030Prob1.dat");
char s[100];
int max = 0;
int count = 0;
string firstName, tempFirstName, lastName, tempLatName;
int id, tempId;
if (inputFile.is_open()) {
while (!inputFile.eof()) {
count++;
inputFile >> s;
if(count % 4 == 1){
tempFirstName = s;
}
else if(count % 4 == 2){
tempLatName = s;
}
else if(count % 4 == 3){
tempId = atoi(s);
}
else if(count % 4 == 0){
double salary = atoi(s);
if(max < salary){
max = salary;
lastName = firstName = tempFirstName;
tempLatName;
id = tempId;
}
}
}
}
cout<<"Maximum Salary: "<<max<<endl;
cout<<"First Name: "<<firstName<<" Last Name:
"<<lastName<<" ID: "<<id<<endl;
inputFile.close();
return 0;
}
Output:
Simple C++: Getting an input file and doing calculations. Input file to be read from should...
Simple C++. Sturctures- Please make sure it compiles. John Harris 1000 Lisa Smith 1002 Adam Johnson 1007 Sheila Smith 1009 Tristen Major 1012 Yannic Lennart 1015 Lorena Emil 1018 Tereza Santeri 1020 Problem 1. Structures (10 points) A company keeps its employee databases in two text files. The first file contains the first name, the last name and ID in the following format First Name LastName ID This is provided to you as filel.txt The second file contains the ID,...
Write a Java program to read customer details from an input text file corresponding to problem under PA07/Q1, Movie Ticketing System The input text file i.e. customers.txt has customer details in the following format: A sample data line is provided below. “John Doe”, 1234, “Movie 1”, 12.99, 1.99, 2.15, 13.99 Customer Name Member ID Movie Name Ticket Cost Total Discount Sales Tax Net Movie Ticket Cost Note: if a customer is non-member, then the corresponding memberID field is empty in...
Description: This Java program will read in data from a file students.txt that keeps records of some students. Each line in students.txt contains information about one student, including his/her firstname, lastname, gender, major, enrollmentyear and whether he/she is a full-time or part-time student in the following format. FIRSTNAME LASTNAME GENDER MAJORENROLLMENTYEAR FULL/PART The above six fields are separated by a tab key. A user can input a keyword indicating what group of students he is searching for. For example, if...
Write a program that will first receive as input the name of an input file and an output file. It will then read in a list of names, id #s, and balances from the input file specified (call it InFile.txt) which you will create from the data provided below. The program will then prompt the user for a name to search for, when it finds the name it will output to a file (call it OFile.txt) the person’s id#, name,...
Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...
Solve it for java Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...