C++ :: Write A Program That Find A Years Day?
Aug 12, 2014Given that today is June 9, thursday, write a program that will print the day of the week on June 9, after x years from now. Assume one year is 365 days.
View 2 RepliesGiven that today is June 9, thursday, write a program that will print the day of the week on June 9, after x years from now. Assume one year is 365 days.
View 2 Replieswrite a C++ program to find the area of a square, input the length of the side, and output your answer to the screen.
View 3 Replies View Relateduser enter four number and the output will be the greatestt number among these
View 1 Replies View Related#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
[Code]....
Write a program that outputs inflation rates for two successive years and whether the inflation is increasing or decreasing. Ask the user to input the current price of an item and its price one year and two years ago.
To calculate the inflation rate for a year, Uh, no, that’s wrong! To calculate the inflation rate for a year, subtract the price of the item ONE YEAR AGO from the price of the item for that year and then divide the result by the price a year ago. For example: 2014-Inflation-Rate = (2014-Price minus 2013-Price) / 2013-Price.
Your program must contain at least the following functions:
•a function to get the input
•a function to calculate the results
•a function to output the results
Your objective is to write a program that calculates the simple interest for a given loan amount and duration (in years).
Formula:
Simple interest = loan amount X interest rate X number of years
Assume interest rate is a constant 6% per year.
Specifically, your program will:
1. Output descriptive header
2. Prompt and read any customer’s first name, middle initial, and last name individually
3. Prompt and read the principal/loan amount
4. Prompt and read the duration of the loan in years
5. Calculate the interest
6. Output:
a. Customer full name
b. Principal/loan amount
c. Duration of loan
d. Interest rate
e. Interest on loan
f. Principal and interest due at end of term
OK SO THIS IS MY PROGRAM SO FAR. As you can see i got it all but i am so confused with as to for loan amount and duration of year, if i should use float or double to declare it?
i need to finish this assignment by calculating the simple interest and i dont know how or where to begin.
int main(){
system("color f0");
string firstName;
string middleInitial;
string lastName;
cout<<"Please enter your First Name: ";
[Code]...
Write a C++ program to estimate the springtime count of deer in a park for 10 consecutive years. The population of any given year depends on the previous year's population according to the following calculation:
• If the lowest winter temperature was less than 0 degrees, the deer population drops by 15%.
• If the lowest winter temperature was between 0 degrees F and 25 degrees F (inclusive), the deer population drops by 10%.
• If the lowest winter temperature was between 26 degrees F and 30 degrees F (inclusive), the deer population doesn’t change.
• If the lowest winter temperature was between 31 degrees F and 35 degrees F (inclusive), the deer population rises by 12%.
• If the lowest winter temperature was higher than 35 degrees F, the deer population rises by 14%.
I have started with:
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
int main() {
int year;
int pop1;
[Code] ....
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h>
int is_prime( int num );
int get_positive_integer(void);
int main( ) {
int upper; /* upper limit to check */
int num; /* current number to check */
int isprime;
/* used to flag if number is prime or not */
[Code]...
It says the error is on line 23
I'm new in programming, and trying to write a code in C. The requirement is following - to write a text, and to find frequency of 1 chosen character in it. The main thing is that program should check user input (for example, I want to check if user entered "char" --> then correct, or if entered "int" --> not correct). But the program still doesn't check. So I have:
Code:
#include <stdio.h>
int main(){
char c[1000], ch;
char i, count=0;
printf("Enter a text: ");
gets(c);
[Code] ....
Am I on my right way using if/else?
im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.
void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];
[Code]...
For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?
I have a batch of .pdf files (~1000) with names 001.pdf 002.pdf ...etc. Still pretty new to C, but would it be possible to write a program that would open a PDF, prompt a new name from user, and when entered, close the .pdf and open the next one in the list?
View 14 Replies View RelatedI want to write a bootable c/c++ Hello World. How can i do that?
View 2 Replies View RelatedSo I am trying to write a program that has 3 subcategories under the category section. the subcategories are donuts, drinks and chips
struct Inv
{
double sku;
char category[SIZE];
[Code].....
I have to make the subsections here so the user can choose the category.
Here I was trying to write a program to copy one file to another.
Code:
#include <stdio.h>#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp , *ft;
[Code]....
So it should copy test1 to test2. Now I created test1 in gedit. I just put one character "c" in it and closed it. And I ran the program. When I check sizes of test1 and test2 , using
ls -l
command, I see that test2 has 4 bytes and test1 has 2 bytes. So something strange is happening here. I just put a single character in test1, so shouldn't it show 1 byte ? And why test2 is showing 4 bytes ? I have Win XP on my laptop. And I use Ubuntu 12 inside VirtualBox. So this is Linux environment...
I recently signed up for ES201 class and am confused with how to compile a program in the C language that will convert ACT scores to SAT scores.
View 5 Replies View Related-Create three files namely all_numbers, odd_number and even_number.
-Get the number of records and the numbers to store from the user.
-Save all the numbers in "all_numbers" file.
-Read each number and check whether it is odd or even.
-Store the odd numbers in odd_number file and even numbers in even_number file.
-Finally, print the numbers stored in odd_number and even_number files.
The output of the program will look like this.
How many records that you want to store :41
2
3
4
The data are written too the respective files.
The even numbers are 2 4
The odd numbers are 1 3
I would like to write a program that gives you a few default values. Now you can keep these values by pressing the enter key or you can change them by just typing in new ones and confirm the new values by pressing the enter key again.
Thats as far as i got on my own but it doesn't really work. what i can do to fix this.
Code:
#include<stdio.h>
#include <conio.h>
int getInt(int min, int max);
int main () {
int a[3] = {3,4};
int b;
int code;
[Code]...
I need to write a program that tells the day of the week, month, day, year, and whether it is a leap year or not from a input of MM DD YYYY form.
Example: Enter numeric values for month, day and year of a date> 10 31 1990 Wednesday, October 31, 1990 occurred in a non-leap year.
#include <iostream>
using namespace std;
int main()
{
int num = 2;
int count = 0;
while (num <= 100)
[Code]...
The code works fine but I need the results to print out like
2 4 6 8 10 12 14 16 18 20
22 24 26 28 30 32 34 36 38 40
instead of
2
4
6
8
10
12
I don't know how to do this.
So I am trying to write a program that asks the user for a name. If the user enter the right name the program ends but if the user were to enter the wrong name the program would enter a loop prompting the user to re-enter the name. However I am not able to get the program to work!
View 9 Replies View RelatedI have a problem. I want to write a program that gives me the current calender for example like this:
June 2009
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
and I shouldn't use windows.h
I assume floating point numbers in C++ have a default maximum of 5 decimal places. You can use setprecision() but is this limitless?
So how would find say write a program to calculate Pi to N number of places?
My tasks was to write a program which finds difference between two arrays (elements which are in first array but not in second and vice-versa). Program works, but something wrong is with the memory allocation for array.
My code is:
main.c Code: #include <stdio.h>
#include <stdlib.h>
#include "header.h"
[Code]....
Write a program with two functions both called from main(). The first function just prints "Hello". In the second function ask the user to enter a number. Calculate the square root of the number and return the result to main(). In main() print the square root value.
Code:
#include<stdio.h>
#include<math.h>
float fun3 (float );
main()
}
[code]...
Write a program that reads data from a file (use the attached data file). These data are a student name and 3 test scores. The program should calculate the average of the 3 test scores, and display the name, 3 test scores, and the average to the monitor.
Useful tips:
a) Include the following header files: iostream, fstream, iomanip, and string
b) The name of the data file is “datafile.txt”, you need to save the file in the same folder of the source file.
c) use the manipulators (setw, setprecision, setfill, showpoint, fixed) to format the average with 1 digits after decimal point as following.
d) Use character ‘ ’ for tab.
i try to write a postfix calculator program using stack in C++ the in put must be the infix expression but can dont know how to write a infix expression in put.
this is my code :
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
using namespace std;
}
[code]....