I am writing a program that can take input from a user or file of positive and negative numbers. Then display them in a html table. The negative numbers have to be outputted in red html font on the table and the positive numbers will just be outputted. I wrote a loop that shouldn't terminate till a zero is entered. For some reason it won't print my table. This is what I have so far if anyone can shine some light on this for me I would be gratefull. -
#include <iostream>
-
using namespace std;
-
-
int main() {
-
-
cout << "<html>";
-
cout << "<body>";
-
cout << "<table>";
-
-
int value1,value2,value3;
-
-
cout << "<tr><td>"<< "1"<< "</td>";
-
cout << "<td>"<< "2" << "</td>";
-
cout << "<td>"<< "3"<< "</td>";
-
cout << "<td>"<< "Sum"<< "</td></tr>" << endl;
-
int sum;
-
int count = 1;
-
while (count > 0) //infinite loop that will only be broken if zero is a input.
-
{
-
cin >> value1 >> value2 >> value3;
-
while(value1 == 0)
-
{
-
cout << "<tr><td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
sum = value1;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
if (value1 > 0)
-
cout << "<tr><td>"<< value1<<" </td>";
-
else;
-
cout << "<td><font color=red>" << value1 << "</font></td>";
-
-
while(value2 == 0)
-
{
-
cout << "<td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
sum = value1+value2;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
-
if (value2 > 0)
-
cout << "<tr><td>"<< value2 << " </td>";
-
else;
-
cout << "<td><font color=red>"<< value2 << " </font></td>";
-
-
while(value3 == 0)
-
{
-
cout << "<td>" << " " << " </td>";
-
sum = value1+value2+value3;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
-
if (value3 > 0)
-
cout << "<tr><td>" << value3 <<"</td>";
-
else;
-
cout << "<td><font color=red>" << value3 << "</font></td>";
-
sum = value1 + value2 + value3;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>" << endl;
-
}
-
cout << "</html>";
-
cout << "</body>";
-
cout << "</table>" << endl;
-
-
return 0;
-
-
}
1 3424 sicarie 4,677
Recognized Expert Moderator Specialist
I am writing a program that can take input from a user or file of positive and negative numbers. Then display them in a html table. The negative numbers have to be outputted in red html font on the table and the positive numbers will just be outputted. I wrote a loop that shouldn't terminate till a zero is entered. For some reason it won't print my table. This is what I have so far if anyone can shine some light on this for me I would be gratefull. -
#include <iostream>
-
using namespace std;
-
-
int main() {
-
-
cout << "<html>";
-
cout << "<body>";
-
cout << "<table>";
-
-
int value1,value2,value3;
-
-
cout << "<tr><td>"<< "1"<< "</td>";
-
cout << "<td>"<< "2" << "</td>";
-
cout << "<td>"<< "3"<< "</td>";
-
cout << "<td>"<< "Sum"<< "</td></tr>" << endl;
-
int sum;
-
int count = 1;
-
while (count > 0) //infinite loop that will only be broken if zero is a input.
-
{
-
cin >> value1 >> value2 >> value3;
-
while(value1 == 0)
-
{
-
cout << "<tr><td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
sum = value1;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
if (value1 > 0)
-
cout << "<tr><td>"<< value1<<" </td>";
-
else;
-
cout << "<td><font color=red>" << value1 << "</font></td>";
-
-
while(value2 == 0)
-
{
-
cout << "<td>" << " " << " </td>";
-
cout << "<td>" << " " << " </td>";
-
sum = value1+value2;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
-
if (value2 > 0)
-
cout << "<tr><td>"<< value2 << " </td>";
-
else;
-
cout << "<td><font color=red>"<< value2 << " </font></td>";
-
-
while(value3 == 0)
-
{
-
cout << "<td>" << " " << " </td>";
-
sum = value1+value2+value3;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>";
-
}
-
break;
-
-
if (value3 > 0)
-
cout << "<tr><td>" << value3 <<"</td>";
-
else;
-
cout << "<td><font color=red>" << value3 << "</font></td>";
-
sum = value1 + value2 + value3;
-
cout << "<td>" << sum << " </td>";
-
cout << "</tr>" << endl;
-
}
-
cout << "</html>";
-
cout << "</body>";
-
cout << "</table>" << endl;
-
-
return 0;
-
-
}
You use breaks after the inner while loops - that pulls you out, no matter what (I think you might want an if statement - if the first while loop was entered, then break...). Also, I'm not sure if you mean to have those ';'s after the else statements - they signify that the else is empty and the cout statements after that will be run, even if the else condition is not met (just in case that was not by design - I have seen that used, and used it myself before).
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Guinness Mann |
last post by:
Greetings,
I think I saw an article yesterday in which you told someone not to make
an Identity column a primary key. I seem to remember you saying
something like "It undermines the entire foundation of the relational
model."
I've been thinking about that all night and I think I understand what
you're saying, but I have some questions.
|
by: David Cleaver |
last post by:
Hello all,
I was wondering if there were some sort of limitations on the "if"
statement? I'm writing a program which needs to check a bunch of
conditions all at the same time (basically). And I'm pretty sure the
rest of the program is working just fine. The only thing I could think
might be wrong is that the if statement can only hold so many values in
itself? Let me show what I'm doing:
if (table001]>>5]&b&0x1f] != 0 &&
|
by: Mario Reiley |
last post by:
Hi, Group
I need transfer a listView.Item's data control to Windows Clipboard for
retrive in MS-Excel or another program.
Some Idea , some code, may be WEB site which advisor will be wellcome.
Best Regard
Mario
|
by: MP |
last post by:
Greets,
context: vb6/ado/.mdb/jet 4.0 (no access)/sql
beginning learner, first database, planning stages
(I think the underlying question here is whether to normalize or not to
normalize this one data field - but i'm not sure)
:-)
Background info:
|
by: Patrick.O.Ige |
last post by:
I have a xml file and i want to format it using XSL
I needed to do a distinct which is ok on the first node "Code"
But when it gets to the "programDescription" node it prints out values for
both Code="PRG004"
and PRG005 which is CrazyTraining 2 and Program6
I want CrazyTraining 2 for PRG004 and Program6 for PRG005
Any help?
Thx
| |
by: raskovsky |
last post by:
Hello, I'm new to access, I've used vc++ and sql, but I was required
to program this project in access. I have two questions in one.
First let me explain my program. It's a huge database which takes the
accounting of a construction company. One of the most important things
of the program is to load all the bills of the different suppliers. The
problem I have is that one bill can be divided for two or more projects
with different amounts...
|
by: David Eades |
last post by:
Hi all
Complete newbie here, so apologies if this is the wrong forum.
I've been asked to use mysql and asp to make a simple bidding system (rather
like a simple ebay), whereby users can use a web browser to view a highest
bid and can make a bid.
My question is; how can I be sure that when a user submits a bid, that
another user isn't also currently submittimg a bid, i.e i can tell user A
|
by: gdarian216 |
last post by:
the object of the project was to create a program that inputs multiple lines of integers and outputs them in an HTML table. The negative numbers should be red. The numbers should be printed 3 in a row, one number per column. the fourth column should contain the sum of the numbers in the row (agian if the sum is negative it should be outputed in red). Input should stop when zero is entered, but zero shouldn't be printed if there are any more...
|
by: Curtis Rutland |
last post by:
How To Use A Database In Your Program Part II
This article is intended to extend Frinny’s excellent article: How to Use a Database in Your Program. Frinny’s article defines the basic concepts of using databases very well and is prerequisite reading for this article.
Frinny’s article explains how to use a SQL Server in your program, but there are other databases as well. Some of them provide .NET connectors, but for those that don’t,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |