translated from greek to english www onlinedoctranslator com system pr
Search for question
Question
Translated from Greek to English - www.onlinedoctranslator.com
System Programming
Deadline: 13.06.2024
1. Write a smart contract market.sol in Solidity where you will implement a simple
market. The smart contract will have three methods: a) addProduct, b) listProducts,
c) buyProduct. A product is a string name. The market (the smart contract) contains a
"mapping (string=>address) products" with all products and their mapping to
Ethereum addresses (accounts) representing their owners and a
mapping(string=>int32) with all products and their prices. The addProduct method
adds a product (string parameter) with a value (int32 parameter) and msg.sender
(the caller of the function) is set as the owner. The listProducts method returns
the list of products (string[]) and their values (int32[]). The buyProduct method
takes the product (string) as a parameter, and if the money paid (msg.value) is
greater than or equal to the product price, it pays the owner the product price
and changes the owner of the product. Compile, deploy in Ganache and call the
smart contract methods. Write a short report where you provide screenshots of
the above steps and your method calls and how they change the market state
and the balances in users' Ganache accounts. Help: Use one account as seller
and one account as buyer and initially add only one product. Also, for
transferring money, each address has a balance field, so to transfer amount x
from account A to B you can do A.balance -=x? B.balance += x
2. Write in C a countlabels.c program that will use MPI to count the number
of subjects carrying each different label. The data will be read from the
accompanying file in eclass at the location Documents-code/data.zip,
which contains almost 70 thousand lines of the form subject <TAB> tag,
eg, 100000170
African American
The purpose of your program, to be developed with MPI, is for a coordinator
process to read the file and break its processing into multiple chunks, each of
which will count the occurrence count of each different tag and produce pairs of
"tag, crowd" for all the different tags it encountered, and it will send all of these
to the moderator. The moderator reading the results should sum them by tag
and display them on the screen, e.g.
African American 156
Caucasian 342
Hispanic 235