Oct 11, 2012 at 5:55am UTC
call charging program using logical, arithmetic operators and decision statements if, if else, nested if, nested if else,:
if
call start from 8:00am - 19:59pm
call charges = 5rs
if
call start from 20:00pm - 07:59am
call charges = 3rs
what will be the call charges if call start from 19:45 and end at 20:15
???????
need code
Last edited on Oct 17, 2012 at 9:39am UTC
Oct 17, 2012 at 10:17am UTC
if ( startingHour >= 20 && startingHour <=7)
Can you think of any value of startingHour which is bigger than 20 AND less than 7? I can't.
Which bit of code do you think is supposed to be run when you enter 1 as the starting hour? You have not written any code for that.
1 2
#include<iostream.h>
main()
This has not been C++ since before 1998. You should get a new, correct C++ compiler for free instead of whatever 20 year old mess you're using.
Last edited on Oct 17, 2012 at 10:17am UTC
Oct 17, 2012 at 3:50pm UTC
which compiler i should use. my instructor is gave me this. i am using bloodshed DEV-C++
Oct 17, 2012 at 3:50pm UTC
Okay. So, is this true?
startingHour >= 20
No, startingHour is NOT 20 or more.
Is this true?
startingHour <=7
Yes, startingHour is 7 or less.
So are they BOTH true? No.
So is this true?
startingHour >= 20 && startingHour <=7
No, because this will only be true when they are BOTH true.
Pick another number that you think will make
startingHour >= 20 && startingHour <=7
true and I will explain why it does not.
Last edited on Oct 17, 2012 at 3:50pm UTC
Oct 17, 2012 at 3:50pm UTC
is 1 greater than 20?
damn, Moschops'ed...
Last edited on Oct 17, 2012 at 3:51pm UTC
Oct 17, 2012 at 3:53pm UTC
Moschops i got it. can i use OR operator instead of AND??????
Oct 17, 2012 at 3:53pm UTC
Can you?????? We're not here to do your homework for you.
Last edited on Oct 17, 2012 at 3:54pm UTC
Oct 17, 2012 at 3:54pm UTC
if ( startingHour <= 20 && startingHour >=7)
i think this is the true statment. but its also not working
Last edited on Oct 17, 2012 at 3:56pm UTC
Oct 17, 2012 at 3:59pm UTC
m not saying to do my home work i am asking for suggestion. well thanks dude :-)
Oct 17, 2012 at 4:01pm UTC
if :
if( startingHour >= 8 && startingHour <=19)
give you one charge, what descision has been made about the other charge?
(hint : i'll charge you this, else i'll charge you that)
Oct 17, 2012 at 4:05pm UTC
Moooce
other charges are applying in
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
if ( startingHour >= 8 && startingHour <=19)
{
totalMint = startingMint + callDuration;
if ( totalMint>= 60)
{
startingHour + 1;
}
if ( startingHour >= 20)
{
totalCharges = (59 - startingMint)*5 +(totalMint - 59)*3;
}
else
{
totalCharges = callDuration * 5;
}
}
but the code for these charges is not working
f
call start from 20:00pm - 07:59am
call charges = 3rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
else
{
if ( startingHour >= 20 || startingHour <=7)
{
totalMint = startingMint + callDuration;
if ( totalMint>= 60)
{
startingHour + 1;
}
if ( startingHour >= 8)
{
totalCharges = (59 - startingMint)*3 +(totalMint - 59)*5;
}
else
{
totalCharges = callDuration * 3;
}
}
}
i am unable to find what will be the right statment in
if ( startingHour >= 20 || startingHour <=7)
Last edited on Oct 17, 2012 at 4:14pm UTC