C++ :: Printing Number Of Days In A Month
Dec 17, 2013
I write this program to print the number of days for the month when the year and the month enters. This is not giving any result and i think that problem is with calling functions.
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
int leap_year(int year);
string days(string mounth);
string feb(string fab1);
void main(){
int year;
View 8 Replies
ADVERTISEMENT
Oct 29, 2013
program that prompts the user to enter a person’s date of birth in numeric form such as 8-27-1980.The program then outputs the date of birth in the form: august 27, 1980.Your program must contain at least two exception classes; invalidDay and invalidMonth.
View 1 Replies
View Related
Mar 17, 2013
i am beginner in c++ , i need to write a programm that out ouputs a calender for a month when given a month and year using this frame work :
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
using namespace std;
[code].....
View 8 Replies
View Related
Mar 19, 2014
I have a code that calculates the number of days between dates. It considers leap years and different days among months. The problem I have is when i debug the code nothing comes out.
Here is the code.
#include<iostream>
#include<fstream>
using namespace std;
bool wheep();
int daysinmonth();
bool wheep(int yr) {
if (yr % 400 == 0)
[Code] ....
this is the file its reading
1 7 9 1 10 9
View 3 Replies
View Related
Mar 24, 2014
I have an assignment to write a program that will calculate the number of days between two dates (including leap years). We have to read the data from a file and in my current input file I have:
1 1 2000 1 5 2004
5 2 2005 2 5 2009
1 15 1998 1 15 2001
for testing purposes. When I run the program the console runs continuously spouting out "The days between your two dates are 1097." Which would be the correct output for the last set of dates entered, but I need to find out where I've messed up in my main.
#include <iostream>
#include <fstream>
using namespace std;
bool isLeap(int x) {
if (x % 400 == 0) {
[Code] .....
View 7 Replies
View Related
Oct 21, 2012
Can not even say this is the error as it is giving me 45 errors. l am writing code which accept employee type based on calculating the miles traveled in a year,my code is based on type of employee, number of vacation days used and no of sick days used.
#include <iostream>
#include <iomanip>
#include <conio.h>
class employee {
int emp_type;
float emp_vacation;
[Code] ....
View 11 Replies
View Related
Feb 22, 2014
Create a class to store a value that represents number of hours worked and number of days worked. Must ensure that the two representations are always consistent. I have to create 2 files, I'm pretty sure: a .cpp and a .h
This is what I have so far for my .h file (I know it's NOT functional...yet):
#include <iostream>
using namespace std;
class NumDays {
private:
double hours;
double days;
[Code] ...
I don't know how to start / create this .cpp file to define the variables.
View 3 Replies
View Related
Feb 14, 2015
Whenever I run the program I get no errors yet it doesn't return a value for total it just exits the program. The program is supposed to output the number of the day based on the month day and year and check whether it is a leap year.
#include <iostream>
using namespace std;
int totaldays();
int days();
int month, day, year;
bool leap();
int main() {
char dash;
cout << "Enter the date in mm-dd-yyyy format to find out what day this is in the year." << endl;
[Code] ....
View 2 Replies
View Related
Apr 15, 2014
I'm taking a C++ computer science course right now, and one of the questions on my latest assignment is this:
"A partition of an integer n is a way of writing n as a sum of positive integers. For example, for n=7, a partition is 1+1+5. Write a program that finds all the partitions of an integer n using r integers. For example, all the partitions of n=7 using r=3 integers are 1+1+5, 1+2+4, 1+3+3, 2+2+3."
I've been struggling with this problem for a couple days now, and how to do it. I understand I need a recursive function to grab variables, and probably an array or vector to store them, but where to begin.
I've been reading documents on partition generating and the concept still eludes me, and any other questions on here or other programming sites using partitions don't seem to have a constraint on them.
View 2 Replies
View Related
Mar 22, 2015
I've got this assignment where I have to print every other number from 1 to 10.
so far I've got this.
#include <iostream>
using namespace std;
int main() {
[Code].....
wondering if its really counting from 1 to 10 and only printing every other number.
View 9 Replies
View Related
Mar 6, 2015
have this program .. i tried to make it work to give me this result output:
Code:
input array {1,3,5,1,1,8,6,6,1,3,2,1,6,8,8}
[0]
[1] *****
[2]*
[Code].....
instead i'm having asterisks at the end of the output
View 14 Replies
View Related
Feb 28, 2013
The program requires the user to enter 10 integers then print the total no. of even integer,highest even integer, lowest even integer then total no. of odd integer,highest odd integer, lowest odd integer
I already got the total no. of even integer and total no. of odd integer. But I don't know how will i get the highest even integer, lowest even integer and highest odd integer, lowest odd integer.
View 2 Replies
View Related
Feb 8, 2013
I have been trying to write a recursive function to print the permutations of a n-digit number. This is the logic that i am trying to use.
1.call the permutation function,
2.keep the first digit in the first place and send the remaining 2 digits back to the permutation function recursively.
3.keep one of the two digits received and send the remaining digit to the permute function.
4. keep doing this till only one digit remains. this is the smallest solution so return it.
View 3 Replies
View Related
Jan 9, 2015
how to make a program in which a user is prompted to input four numbers like 1234 and then print those four numbers one by one on screen using only one variable..??
For example:
1
2
3
4
in ascending order...
I've done that with two methods but i am not sure whether the methods were correct..
View 1 Replies
View Related
Mar 6, 2015
Program that has the user enter 5 digits then asks the user what they want to know about the 5 digits. My issue is when the program goes to print the value, its a totally ill related number
10 34 8 17 50
program prints out:
2 for smallest
79 for largest
119 for sum
23.80 for average
Code:
#include <stdio.h>#include <stdlib.h>
int main(void)
{
int smallNum, largNum, count=0, sum=0, value, choice;
double avgNum;
printf("Enter 5 integers
");
printf("
");
[Code]...
View 7 Replies
View Related
Mar 18, 2012
Why my program doesn't work? Print number of vowels case-insensitively. For instance in the expression “come here”, there are 4 vowels.
#include <stdio.h>
#include <stdlib.h>
int vowels(char sentence[], char vowelletters[], int max) {
int vowelcounter=0;
int i,j=0;
[Code] ....
it just count one vowels not more.
View 2 Replies
View Related
Sep 20, 2013
I want to have one case of my switch statement to print out how many times the user has chosen other cases in the switch statement. Such as "You have pressed 2 6 times and 4 3 times."
View 3 Replies
View Related
Jul 1, 2013
I'm trying to determine the first Tuesday of any month in a given year.. I'd prefer to use my own functions to arrive at a solution, but logically I could sorting these things out.
View 6 Replies
View Related
Apr 10, 2013
I am having trouble associating the month names with the month numbers. When the program runs, it should output the date in three styles.
Also I do not know if my input validations work correctly(day cannot be greater than 31 or less than 1, month cannot be greater than 12 or less than 1).
#include <iostream>
using namespace std;
char again;
class Date {
private:
int month;
int day;
int year;
[Code] ....
View 7 Replies
View Related
Oct 21, 2013
So my program is suppose to calculate the rain totals for the month but I get a weird error I've never seen.
ERROR: Unresolved external symbol "double_cdecl wettestMonth(double*const,int)" (?wettestMonth@@YANQANH@Z) referenced in function_main
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
//Function Prototypes
double getData();
[Code] ....
View 1 Replies
View Related
May 2, 2013
The objective is to build a month class that hold data on the number of the month and the name of the month. Using constructors and overloads, set it up to where you can input either the month or the name and it will output the results for both the month number and name.
Here is the code I have so far:
#include<iostream>
#include<string>
using namespace std;
class Month{
private: string name;
int monthNumber;
[Code] ....
It is almost fully compiled if I go by the error list. The only problems I see to be having are with the prefix and postfix overloads.
View 5 Replies
View Related
Oct 18, 2013
So for my C++ class I am required to create a program that will "Write a program to generate a calendar for a year. The program should accept the year and the day of the week for january 1 of that year (0=Sunday, 1=Monday, etc.)" (problem statement) and I am completely stuck. I've posted what I have so far below:
#include <iostream>
#include <iomanip>
using namespace std;
bool isLeapYear(int year);
int daysInMonth(int month, bool lpYear);
int printCalendar(int month);
int printDay(int dow);
[Code] .....
View 3 Replies
View Related
Dec 11, 2014
(I'm using visual c++). Write a program that calculates the balance of a savings account at the end of a three month
period. It should ask the user for the starting balance and the annual interest rate. A loop should then iterate once for every month in the period, performing the following:
A) Ask the user for the total amount deposited into the account during that month. Do not accept negative numbers. This amount should be added to the balance.
B) Ask the user for the total amount withdrawn from the account during that month. Do not accept negative numbers or numbers greater than the balance after the deposits for the month have been added in.
C) Calculate the interest for that month. The monthly interest rate is the annual interest rate divided by 12. Multiply the monthly interest rate by the average of that month’s starting and ending balance to get the interest amount for the
month. This amount should be added to the balance.
After the last iteration, the program should display a final report that includes the following information:
• starting balance at the beginning of the three-month period.
• total deposits made during the three months
• total withdrawals made during the three months
• total interest posted to the account during the three months
• final balance.
What I need is to solve that particular problem using a class. Here is the code solved for the problem not using a class:
#include<iostream>
using namespace std;
int main() {
double annulInterestRate,
balance,
monthlyInterestRate,
[Code] .....
View 8 Replies
View Related
Nov 10, 2014
In this assignment the student should develop a month calendar by designing a class called calendarType . This class uses two other classes (dateType and dayType) as described below:
1. dayType Class: This class has been designed by students in Lab1 exercises. Referee to it.
2. dateType Class: This class is designed and implemented to keep track of data. This class has been provided it to you. Study it first then add definitions and implementations of the following operations to this class:
- Test whether the year is a leap year. Leap year is identified by 3 criteria :
- The year is evenly divisible by 4;
- If the year can be evenly divided by 100, it is NOT a leap year, unless;
- The year is also evenly divisible by 400. Then it is a leap year.
- Return the number of days in the month. For example, if the date is 12/3/2014, the number of days to be returned is 31 because there are 31 days in March.
- Return the number of days passed in the year. For example, if the date is 18/3/2014 the number of days passed is 77. Note that the number of days returned also includes the current day.
- Return the number of days remaining in the year. For example, if the date is
18/3/2014 , the number of days remaining in the year is 288.
- Calculate the new date by adding a fixed number of days to the date. For example, if the date is 18/3/2014 and the days to be added are 25, the new date is 12/4/2014.
To print monthly calendar using calendarType class, you must know the first day of the month and the number of the days in that month. Thus, you must store the first day of the month, which is in the form of dayType and the month and the year of the calendar. Clearly, the month and the year can be stored as an object of the form dateType by setting the day component of the date to 1, and the month and year as specified by user.
Design the class calendarType so that the program print a calendar for any month starting 1/1/ 1500 which is Monday. To calculate the first day of a month, you can add the 2 appropriate days to Monday of January 1, 1500. For this class identify and implement the following operations:
- Determine the first day of the month for which the calendar will be printed. Call this operation firstDayOfMonth.
- set/get month.
- set/get year.
- Print calendar for particular month.
- Add the appropriate constructors to initialize the member variables.
- Write a test program to print the calendar for either a particular year or a particular month.
View 1 Replies
View Related
Feb 10, 2015
I am in a computer science class at LSU and i can not figure out how to writhe this program. The program must let the user input (MM/DD/YYYY) and then output what day that date was on and also if it was a leap year or not.
View 1 Replies
View Related
Apr 25, 2013
how to search and display the total between 2 days without using lots of code
View 3 Replies
View Related