Helpp plaaa
I have a test coming up next week and the question is like this:
a)Write a program to display the following two prompts:
i)Enter a month (use a1 for Jan, etc)
ii)Enter a day of the month
Have your program accept and store a number in the variable month in response to the first prompy, and accept and store a number in the variable day in response to the second prompt. If the month entered is not between 1 and 12 inclusive, print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31, print a message informing the user that an invalid day has been entered.
This is my first exam i'm starting in sem1 currently. I'm really lost any code snippets will be much apprecited or a plain explanation on starting is ok. I dont expect the whole answer
a)Write a program to display the following two prompts:
i)Enter a month (use a1 for Jan, etc)
ii)Enter a day of the month
Have your program accept and store a number in the variable month in response to the first prompy, and accept and store a number in the variable day in response to the second prompt. If the month entered is not between 1 and 12 inclusive, print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31, print a message informing the user that an invalid day has been entered.
This is my first exam i'm starting in sem1 currently. I'm really lost any code snippets will be much apprecited or a plain explanation on starting is ok. I dont expect the whole answer
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
Do u have visual studio? (2000 or better)No-1 wrote: I have a test coming up next week and the question is like this:
a)Write a program to display the following two prompts:
i)Enter a month (use a1 for Jan, etc)
ii)Enter a day of the month
Have your program accept and store a number in the variable month in response to the first prompy, and accept and store a number in the variable day in response to the second prompt. If the month entered is not between 1 and 12 inclusive, print a message informing the user that an invalid month has been entered. If the day entered is not between 1 and 31, print a message informing the user that an invalid day has been entered.
This is my first exam i'm starting in sem1 currently. I'm really lost any code snippets will be much apprecited or a plain explanation on starting is ok. I dont expect the whole answer
Because theres ready tools for that sort of thing, or is it cheating

<span style='color:blue'><span style='font-size:19pt;line-height:100%'><u><b>FUCK Helbreath!</b></u></span></span><br><br><span style='color:gray'><a href='http://www2.analystica.com/users/anttu/online/ngd' target='_blank'>ngdnetwork</a> OFFICIAL WEBSITE OF Northern Game Developers. Do visit! (THEY ARE UP!)<br><a href='http://project3d.x.am' target='_blank'>Project3d development forum</a> plz join and discuss,develop,give ideas,feedback. Anything goes as long it helps the project!</span><br><br>Zepto Znote 6625WD: 1.8Ghz dual core, 2GB, 512mb graphics card(dedicated), 160GB HDD<br><img src='http://www.signaturebar.com/uploads/images/10111.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/13229.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/8852.png' border='0' alt='user posted image' />
1. What lang should this be written in?
2. Is this to be handed in or written under test conditions?
3. How much will you pay?
Naw just fucking around with the 3rd question haha. 1st semester I'm guessing Java for some friendly OO.
2. Is this to be handed in or written under test conditions?
3. How much will you pay?
Naw just fucking around with the 3rd question haha. 1st semester I'm guessing Java for some friendly OO.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
<?
if(isset($submit)){
if ($_POST['month'] =< 12 && $_POST['month'] => 1){
$month = $_POST['month'];
}else{
echo 'Invalid Month';
}
if ($_POST['day'] =< 12 && $_POST['day'] => 1){
$month = $_POST['day'];
}else{
echo 'Invalid day';
}
}
?>
<form method="post" action="index.php">
Month<textarea rows="1" cols="2" wrap="physcial" name="month"><br>
Day<textarea rows="1" cols="2" wrap="physcial" name="day">
<input type="submit" name="submit" value="Submit">
</form>
there php script im drunk enjoy
if(isset($submit)){
if ($_POST['month'] =< 12 && $_POST['month'] => 1){
$month = $_POST['month'];
}else{
echo 'Invalid Month';
}
if ($_POST['day'] =< 12 && $_POST['day'] => 1){
$month = $_POST['day'];
}else{
echo 'Invalid day';
}
}
?>
<form method="post" action="index.php">
Month<textarea rows="1" cols="2" wrap="physcial" name="month"><br>
Day<textarea rows="1" cols="2" wrap="physcial" name="day">
<input type="submit" name="submit" value="Submit">
</form>
there php script im drunk enjoy

Girlfriends are dedicated hookers.
lol charlie
<span style='color:blue'><span style='font-size:19pt;line-height:100%'><u><b>FUCK Helbreath!</b></u></span></span><br><br><span style='color:gray'><a href='http://www2.analystica.com/users/anttu/online/ngd' target='_blank'>ngdnetwork</a> OFFICIAL WEBSITE OF Northern Game Developers. Do visit! (THEY ARE UP!)<br><a href='http://project3d.x.am' target='_blank'>Project3d development forum</a> plz join and discuss,develop,give ideas,feedback. Anything goes as long it helps the project!</span><br><br>Zepto Znote 6625WD: 1.8Ghz dual core, 2GB, 512mb graphics card(dedicated), 160GB HDD<br><img src='http://www.signaturebar.com/uploads/images/10111.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/13229.jpg' border='0' alt='user posted image' /><br><img src='http://www.signaturebar.com/uploads/images/8852.png' border='0' alt='user posted image' />
it must be written in c++ cin cout bla bla bla..helpp
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
You didn't specify much so i just basically copied charlie's in C++ using cin/cout.
If you keep entering invalid numbers then the input will loop untill you enter the correct value. Just dont enter characters as input coz i don't remember how to quick fix that on consoles lol. Jimmy will probably know how if he browses this topic.
If you keep entering invalid numbers then the input will loop untill you enter the correct value. Just dont enter characters as input coz i don't remember how to quick fix that on consoles lol. Jimmy will probably know how if he browses this topic.
Code: Select all
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int iMonth, iDay;
cout << "Input the Month: ";
cin >> iMonth;
while(iMonth < 1 || iMonth > 12)
{
cout << "Invalid input! The Month must be between 1~12\n";
cout << "Input the Month: ";
cin >> iMonth;
}
cout << "Input the Day: ";
cin >> iDay;
while(iDay < 1 || iDay > 31)
{
cout << "Invalid input! The Day must be between 1~31\n";
cout << "Input the Day: ";
cin >> iDay;
}
system("PAUSE");
return 0;
}
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
Heck i don't even know what the teacher wants. I'll go get an explanation but guys i haven't learn to use the command while or system("PAUSE") or <cstdlib> so far its <iostream> and <cmath> and the commands to use is cout cin if else if and stuff like that
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
Opps double post shit..
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
Sry triple post
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
While is just a loop. The condition is the same as an if statement, it's selectional can be either true or false.No-1 wrote: Heck i don't even know what the teacher wants. I'll go get an explanation but guys i haven't learn to use the command while or system("PAUSE") or <cstdlib> so far its <iostream> and <cmath> and the commands to use is cout cin if else if and stuff like that
If its true then the contents of the loop is ran(like an if statement). Here where it changes, when the loop finishes it goes back to the top and checks the condition again. See what i mean by loop? And also how it's a while? When it gets to checking the condition again if it's false the loop will be skipped(like an if statement). Any tutorial on the net will teach you this in more detail within 5~10min. Take a look at this in the actual code and you should see how it works though.while(condition == true) <----
{
... // contents
}
About cstdlib and system("pause"), all they are used for is to pause the console. Remove them both and put another "cin" in the place of system("pause"). Just make it anything it's only there to hault the program for user input before it returns 0 (aka exits). If i was your teacher i think based on your experience i'd pass that.
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int iMonth, January;
January = 1;
cout << "Enter the Month: ";
cin >> iMonth;
if (iMonth < 1 || iMonth > 12)
cout << "The month has the be between 1~12!\n";
cout << "Enter the Month: ";
cin >> iMonth;
system ("PAUSE");
return 0;
}
How come when i do this it wont keep repeating to enter a number between 1~12 instead just close?
Anyway how can i make it say You've enter January if i enter 1
#include <cstdlib>
using namespace std;
int main()
{
int iMonth, January;
January = 1;
cout << "Enter the Month: ";
cin >> iMonth;
if (iMonth < 1 || iMonth > 12)
cout << "The month has the be between 1~12!\n";
cout << "Enter the Month: ";
cin >> iMonth;
system ("PAUSE");
return 0;
}
How come when i do this it wont keep repeating to enter a number between 1~12 instead just close?
Anyway how can i make it say You've enter January if i enter 1
Support Outpost@HBTop50<br><a href='http://hbtop50.berserkvision.com/in.php?id=582' target='_blank'>Outpost@HBTop50</a><br>
Because you're not using the while loop anymore. That loop checked if the input was bad and would continue looping intill the user enters valid numbers. Your code there just checks it once.No-1 wrote:How come when i do this it wont keep repeating to enter a number between 1~12 instead just close?
Cheap but it works lol.No-1 wrote:how can i make it say You've enter January if i enter 1
Code: Select all
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int iMonth, iDay;
cout << "Input the Month: ";
cin >> iMonth;
while(iMonth < 1 || iMonth > 12)
{
cout << "Invalid input! The Month must be between 1~12" << endl;
cout << "Input the Month: ";
cin >> iMonth;
}
cout << "Input the Day: ";
cin >> iDay;
while(iDay < 1 || iDay > 31)
{
cout << "Invalid input! The Day must be between 1~31" << endl;
cout << "Input the Day: ";
cin >> iDay;
}
cout << "You entered: " << iDay;
switch(iDay)
{
case 1:
case 21:
case 31:
cout << "st of ";
break;
case 2:
case 22:
cout << "nd of ";
break;
case 3:
case 23:
cout << "rd of ";
break;
default:
cout << "th of ";
break;
}
switch(iMonth)
{
case 1:
cout << "January" << endl;
break;
case 2:
cout << "February" << endl;
break;
case 3:
cout << "March" << endl;
break;
case 4:
cout << "April" << endl;
break;
case 5:
cout << "May" << endl;
break;
case 6:
cout << "June" << endl;
break;
case 7:
cout << "July" << endl;
break;
case 8:
cout << "August" << endl;
break;
case 9:
cout << "September" << endl;
break;
case 10:
cout << "October" << endl;
break;
case 11:
cout << "November" << endl;
break;
case 12:
cout << "December" << endl;
break;
}
system("PAUSE");
return 0;
}
Input the Day: 22
You entered: 22nd of December
Press any key to continue . . .[/quote]
Reppin' 127.0.0.1!!!<br><br><img src='http://img502.imageshack.us/img502/1348/sig4daxbn2.jpg' border='0' alt='user posted image' /><br><br>I contend that we are both atheists. I just believe in one fewer god than you do. <br>When you understand why you dismiss all the other possible gods, you will <br>understand why I dismiss yours.<br>~ <b>Stephen Roberts</b>