2 Replies - 1182 Views - Last Post: 15 January 2011 - 11:43 PM Rate Topic: -----

#1 CIStania  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 15-January 11

Incrementing and Decrementing Days of the Week

Posted 15 January 2011 - 11:05 AM

Hello,

My name is Tania Cordeiro.

I attend Devry University in Long Beach, CA. I'm getting my Bachelor's degree in Computer Information Systems, with an elective in Computer Forensics.

I'm currently in the Deans List with a GPA of 3.5 and higher. I have already taken a few classes that gave me a glimpse into what my future may hold. I've already learned how to program Visual Logic, and C++.

I have also taking a Networking class. In this class I've learned how to create a Peer-to-Peer network. I've learned how to use WIND2003 and XP, Linux Red Hat.

Here is my project. I'm currently being asked to increment and decrement days of the week. I have been able to gather some information and quickly came up with the following. U see I only have one week to turn this in. The way I've been studing is, I have gone by previous lessons and build on that. I try all assignments to see with compiles and then structure it. I'm at a hault here.

What I need my program to say is :

Enter Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
Thursday

The previous day is: Wednesday
The next day is: Friday


I need to do this for all days.

I appreciate your time and your assistance towards my post. I look forward to hearing from you soon.


Sincerely,
Tania Cordeiro
[email address removed]


#include <fstream>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	ifstream daysFile;//Input file Object
	ifstream previousFile;//Input file Object
	ifstream nextsFile;//Input file Object
	ofstream outputFile; //Output file object // No need to create a file tab one will be created

	
	string data[3][3];
	

	
	string day[3];// to create a file tab click file, click new file, Click text file open, then saves as choose project, and second named file week 7 Exercise - get data from input files as an object
	string previou[3];// create a file tab
	string next[3];//create a file tab
	
	int whichone = 0;

	daysFile.open("days.txt"); // in paranteses are now associated with the object files 
	previousFile.open("previous.txt"); // these are all input files - 
	numbersFile.open("nexts.txt");

	for (int i = 0; i <= 2; i++)
		{
			getline(daysFile, day[i]); // get line in names file there are spaces, store data in names[i]
			getline(previousFile, previou[i]);
			getline(nextsFile, next[i]);
		}
	cout << "Enter Monday, Tuesday, Wednesday, Thursday, Friday, Saturday or Sunday: ";
	cin >> whichone;

	outputFile.open("output.txt");

	outputFile << name[whichone-1] << " The day you have choosen is " << day[whichone-1] << " the previous day is " << previou[whichone-1] << “ and the next day is “ << next{whichone-1] << endl; // cout changes to outputFile, then we have to run it, and then click on file, click open, click file, click output, and DOS screen message will display on the new output file

	daysFile.close(); // to close all files
	previousFile.close();
	nextsFile.close();
	outputFIle.close();

	system("pause");
	return 0;

This post has been edited by skyhawk133: 15 January 2011 - 11:08 AM
Reason for edit:: Added [code] tags like the big red box and image said to do.


Is This A Good Question/Topic? 0
  • +

Replies To: Incrementing and Decrementing Days of the Week

#2 ishkabible  Icon User is offline

  • spelling expret
  • member icon




Reputation: 1622
  • View blog
  • Posts: 5,709
  • Joined: 03-August 09

Re: Incrementing and Decrementing Days of the Week

Posted 15 January 2011 - 11:22 AM

tell us what it dose as apposed to what you expect it to do.
Was This Post Helpful? 0
  • +
  • -

#3 #define  Icon User is online

  • Duke of Err
  • member icon

Reputation: 1345
  • View blog
  • Posts: 4,629
  • Joined: 19-February 09

Re: Incrementing and Decrementing Days of the Week

Posted 15 January 2011 - 11:43 PM

Do you need to use files, seems to be over-working the problem.

Should
string data[3][3];


not be 7 days at least.
string data[7][3];

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1