importPackage(java.io); importPackage(java.lang); // your code goes here // Solidity smart contract code // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract RealEstate { struct Property { string name; uint price; address[] owners; uint[] ownership; } mapping(uint => Property) public properties; mapping(uint => mapping(address => uint)) public ownerships; function createProperty(uint id, string memory name, uint price) public { properties[id] = Property(name, price, new address[](0), new uint[](0)); } function buyOwnership(uint id, uint percentage) public payable { require(properties[id].price * percentage / 100 == msg.value, "Incorrect value sent"); require(percentage > 0 && percentage <= 100, "Invalid percentage"); uint ownership = properties[id].ownership.length; properties[id].ownership.push(percentage); properties[id].owners.push(msg.sender); ownerships[id][msg.sender] = ownership; } function sellOwnership(uint id, uint percentage) public { uint index = ownerships[id][msg.sender]; require(properties[id].ownership[index] == percentage, "Ownership percentage mismatch"); require(percentage > 0 && percentage <= 100, "Invalid percentage"); uint value = properties[id].price * percentage / 100; properties[id].ownership[index] = 0; ownerships[id][msg.sender] = 0; properties[id].owners[index] = properties[id].owners[properties[id].owners.length - 1]; properties[id].owners.pop(); (bool success, ) = payable(msg.sender).call{value: value}(""); require(success, "Transfer failed."); } }