C++ :: Farm Program - Display Characteristics Of Selected Animal
Oct 12, 2014
I need to make a program using public and private classes. I need to make a farm of five animals using the class Animal and the class has to contain charactaristics about animals i.e. speech or number of legs. So when I run the program it should output a number set to each animal and then it would display the characteristics of the selected animal.
IF statement. Really new, so this will be simple I'm sure. I'm essentially just trying to roll a 6 and 20 sided die. I want the statement to run "If 20,then display the randomly selected number for 20".
// auto dice roller #include <iostream> #include <string> #include <ctime> #include <cstdlib> using namespace std;
I am not getting all the records.... when i select the same date in both datetimepicker no record is displayed... i also want the record of the selected dates from both datetime picker..
i wrote this program to display even number from 100-200. But visual c gives me this error with undeling the "a" in if statement. Error1error C2106: '=' : left operand must be l-value
Write a program that displays the first 40 Fibonacci numbers. A Fibonacci number is created by add the previous two, with the first two always being 0 and 1. A partial sequence is as follows:
0, 1, 1, 2, 3, 5, 8, 13, 21,….
Your table must display 6 numbers per row and use a spacing of 10 for each number. Don’t forget to include the header file “iomanip” at the top and use “setw()”. You will need to turn in an algorithm, source code and output.
Here is what i have but i get errors!
#include <iostream> using namespace std; { int FirstNumber = 0; int SecondNumber = 1; int NumberOfNumbers = 2; int NewNumber;
Also is there a way to display the time only instead of the date? How will i change the program to display the time in standard 12 hours, instead of 24 hours?
#include <iostream> #include <time.h> using namespace std; int main() { time_t tim; time(&tim); cout << ctime(&tim); }
Write a program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, so:
(Calories from fat) = (fat grams) * 9
The percentage of calories from fat can be calculated as:
(Calories from fat) / (total calories)
Extend as follow
1. The user first enters from a menu whether it is breakfast (B or b), lunch (L or l) or dinner (D or d). Use character and process by a switch. 2. The threshold for low calorie is different, for breakfast 10%, lunch 20%, dinner 30% (this value has to be assigned to some threshold variable in the above switch). 3. Include validation of menu choice. 4. In case any validation fails, display detailed error and exit the program by calling return 1 or return EXIT_FAILURE 5. Display the % from fat with one decimal digit.
Example 1: What you have to eat: B - breakfast L - lunch D - dinner What you have: C Error: C is not a valid menu choice
Example 2: What you have to eat: B - breakfast L - lunch D - dinner What you have: L How many calories: 600 How many grams of fat: 10 Your food has 15.0% calories from fat It is a low calories food
Process the menu in a switch, setting the threshold as either 10, 20, or 30%. The rest of the program will be the same regardless what was the menu choice.
Incremental development: first do the textbook problem without input validation, then extend with validation, then extend for the additional parts.
IM trying to make a simple program that will display morse code. Ex if you type 0 print should be (-----) and all the way up to 5. The problem is though that all printf displays all the numbers and not executing only the assigned variable.
#include<stdio.h> int main(void) { int a , b , c , d , e, f, x;
I decided to create a simple program to display a menu with options, while that is easy enough I had some difficulty when selecting an option that has options inside which also has an option again. While I had many issues in the past I'm finally finished with it and it works fine, but being new to programming and not knowing various other methods available.
Code: //:::::::::::::::::::::Simple Menu Program:::::::::::::::: //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.
#include <iostream> using namespace std; //Function prototype int sumArray(int); const int NUM_ELEMENTS = 5;
The code is supposed to display the total and averages of the data as well, but cuts off due to an error in the code. The code should also:
1)Print checks for all employees, one per page, sorted by lastname. The first check number, 100, is to be read from a company data file (see requirement 4). The border of each check is important and should not be omitted.
2)Convert the net pay to a text string for each check printed.
3)Print a reference code on each check. The reference code is obtained by combining the first letter of the lastname with all the consonants remaining after removing all vowels (a,e,i,o,u).
4)Use the same employee data found in assignment 2. Use company data, obtained from a text file, for each check printed:
i need the output to display the product of every whole number from 1-3 in a table format.
this is the code i have so far. i know some brackets are missing but i just pasted the meat of the code. when i run the program i keep getting the number 1 displayed in a straight line going on forever
Write a program that will generate, but not display, a three-digit "target" number that has three distinct digits. (Hint: use random number generator.) Then, input a maximum of ten user guesses and for each guess, output the number of hits and matches in the guess. Stop when the user guesses the number or runs out of guesses. For example, if the target is 427, the guess 207 has one hit (7) and one match (2).
I'm new to coding, and I have to write a program to display a class schedule to the user (the classes are entered into the program in strings like this:
in the format of an excel file (the user picks the classes they want to have) that then displays the course title and professor in the correct cell corresponding to the day/time the class meets. I've been googling it, and from what I've read, I think I need to use a csv file, but I don't know how to input the data into the file. I know the general format for how data is entered, but I don't know how to write it into a specific file or if I even have to (we covered txt files very briefly in my class, but never touched csv files).
i want to create a program (in c++ or c#) that will play mp3 files but also display a word file with the lyrics of the mp3 song playing. so if i choose a mp3 file from a list, the lyric file for that song should also be displayed. i have all the mp3 and lyric files saved on the computer so my problem is how can i link the files?
I have to write a program that stores information about students and displays results (Formated). Example-
Inputs ( # of students, First and Last name of student, the gender, age, and hieght. (height inputed as inches and outputed as feet and inches))
Student 2 --------- Jett, Joan Female 100 years old 5' 7"
Ive been falling behind a little due to working late and barely having time for my school work. Coming across several issues, one being an error with GENDER (Error C4700: uninitialized local variable 'gender' used:). As well as how to format the end result, i understand that u have to use #include <iomanip>, but am confused on how to format correctly.
Write a program that creates and displays a table of temperature conversions. Get the starting temperature from the keyboard in degrees Celsius (do not allow input of a value below absolute zero). Also get an integer value to represent the number of degrees to increment for each of a 20 row table (do not allow the increment value to be less than one. The first column will be a row number starting with one, follow by the Celsius value and then the conversions into Fahrenheit, Kelvin, and Rankine. Be sure that all columns are neatly right aligned for a variety of inputs.
Thats what i wrote so far:
#include <iostream> #include <iomanip> using namespace std; int main() { double C,F,K,R,n,a; cout <<"Enter starting temperature in Celsius: "; cin >> C; [Code] ....
Thats what the instructor looking for:
Enter starting temperature in Celsius: -500 ERROR: Temp must be >= -273.15: -273.15 Enter increments in degrees Celsius: 100
I am writing a program to display two statistic sheets for airplane races. with Acceleration being a random number 5-25. for every second it should display a stat for speed, and distance(Both planes)I am at a loss for how to call the functions separate and side by side respectively.
#include <stdio.h> /* function that will identify if line is empty or not */ is_empty(char *buffer) { while(isspace(*buffer)) buffer++; if(*buffer==0x00) return 1;