d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Paying Fg For School Assignment. > Entry Level Programming. Questions/asgn
Add Reply New Topic New Poll
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Dec 5 2012 07:52pm
This is an assignment due tomorrow. Unfortunately I work a job with rigorous hours and have little time to study.

Paying 50 FG for this assignment if its correct, I have more work.

1. Write a program using structures that would store the information like you see
in the picture below. The value doesn’t need to be the same as shown below.
The program should use some loop statements to either input or output those
values. Your program should display the value on the screen (20 points)

Hint: You can use the syntax to define a structure template PartItem. The code shows
only two members initially (Fig 1).
You have to add another data member as shown in
the Fig 2 and then create an array of the structure variable and store the information
inside the members.

PartItem is a structure template made up of two members. Part is the variable of type
struct PartItem.
struct PartItem

{
char Number[10];
float Price;
};

struct PartItem Part;



Member
Posts: 14,235
Joined: Apr 20 2007
Gold: 15.00
Dec 6 2012 02:46am
I dont need your money, this was less than 5 minutes.
Your attitude is bad, and you should feel bad.


Code
#include < stdio.h>

struct PartItem
{
char Number[10];
float Price;
int Qty;
};

int main()
{
PartItem a = { "SMS0123", 0.35f , 10};
PartItem b = { "ABC4567", 0.15f , 20};
PartItem c = { "CDE7325", 1.20f , 30};

PartItem PartA[3] = {a,b,c};

for(int i = 0; i < 3; i++){
 printf("%s %.2f %d\n",PartA[i].Number,PartA[i].Price,PartA[i].Qty);
}
return 0;
}
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Dec 6 2012 10:47am
Quote (kuzdithom @ Dec 6 2012 04:46am)
I dont need your money, this was less than 5 minutes.
Your attitude is bad, and you should feel bad.


Code
#include < stdio.h>

struct PartItem
{
char Number[10];
float Price;
int Qty;
};

int main()
{
PartItem a = { "SMS0123", 0.35f , 10};
PartItem b = { "ABC4567", 0.15f , 20};
PartItem c = { "CDE7325", 1.20f , 30};

PartItem PartA[3] = {a,b,c};

for(int i = 0; i < 3; i++){
 printf("%s %.2f %d\n",PartA[i].Number,PartA[i].Price,PartA[i].Qty);
}
return 0;
}


i interpreted the structure as

Code
struct PartItem
{
  char Number[20];
  double price;
};

struct Parts
{
  PartItem PartItem;
  int Qty;
};

void main()
{
  Parts PartA[3];

//loops to populate array and print
//PartsA[0].PartItem.Number = "somthin222";
//PartsA[0].PartItem.Price = 0.22;
//PartsA[0].Qty = 20;
}


i came to that reasoning of the structs because the PartsItem struct in the image does not contain a Qty integer variable and there is a thick dotted line on the other struct which made me believe Qty was part of the Parts structure that contained the PartsItem structure.

either way quoted post is correct

This post was edited by AbDuCt on Dec 6 2012 10:47am
Member
Posts: 271
Joined: Feb 19 2010
Gold: 130.00
Dec 6 2012 04:05pm
Quote (kuzdithom @ Dec 6 2012 03:46am)
I dont need your money, this was less than 5 minutes.
Your attitude is bad, and you should feel bad.


I'm not sure what I said that shows my attitude is bad? Regardless, I appreciate your code, and knowledge.
As for feeling bad, that I do not. I work an extremely physical job and I'm exhausted at the end of my day..

Thank you AbDuct and Kuzdithom

This post was edited by jriehle87 on Dec 6 2012 04:08pm
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Dec 6 2012 04:34pm
Quote (jriehle87 @ Dec 6 2012 03:05pm)
I'm not sure what I said that shows my attitude is bad? Regardless, I appreciate your code, and knowledge.
As for feeling bad, that I do not. I work an extremely physical job and I'm exhausted at the end of my day..

Thank you AbDuct and Kuzdithom


Yeah, that was comment was kind of random. That said, you may want to spend some extra time going back over the material. This is really super basic stuff, and if you skip over this, you're going to have a *lot* of trouble down the road.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll