Following Kuangshen java, the p50 calculator implementation source code represents only one person. Any deficiencies are welcome to correct, thank you.
package com.kuang.Method; import java.util.Scanner; public class Demo08 { public static void main(String[] args) { String start = “s”; String end = “e”; String str = “0”; String operator = ” 0″; double result = 0; Scanner scanner = new Scanner(System.in); while (true){ System.out.println(“Enter s to Start calculation, or enter e to end calculation:”); str = scanner.next(); if (str.equals(start)){ double num1 = 0; double num2 = 0; System.out.println(“Please enter num1:”); num1 = scanner.nextDouble(); do { System.out.println(“Please enter the command to continue: +, -, *, /, %, clr, e”); operator = scanner.next(); if ((( operator.equals(“+”)) || (operator.equals(“-“)) || (operator.equals(“*”)) || (operator.equals(“/”)) | | (operator.equals(“%”))) { System.out.println(“Please enter num2:”); num2 = scanner.nextDouble(); switch (operator){ case “+”: result = add(num1,num2); break; case “-“: result = sub (num1,num2); break; case “*”: result = mul(num1,num2); break; case “/”: result = div(num1,num2); break; case “%”: result = mod(num1,num2); break; } System.out.println(“The operation result is: “+num1+operator+num2+” = “+result); System.out.println(“========== ===========================”); num1 = result; }else if (operator.equals( “clr”)){ result = 0; System.out.println(“Clear: “+”result” +” = “+result); System.out.println (“====================================”); System.out.println (“Please enter s to continue, please enter any to end”); if (scanner.next().equals(“s”)){ System.out.println(“Please enter num1:” ); num1 = scanner.nextDouble(); }else { System.out.println(“Computation ends”); System.out.println(“== ==================================”); break; } }else if (operator.equals(“e”))…
Can anyone help me, please change the PHP function to JS function, thank you
Could you please help me by changing the PHP function to JS function? Thank you! function bmrs($weight=0,$sex=1,$age){ switch ($age) { case $age> =0 and $age<3: $x=array(1=>array(60.9,-54),2=>array(61.0,-51)); $y=1; break; case $age>=3 and $age <10: $x=array(1=>array(22.7,495),2=>array(22.5,499)); $y=1; break; case $age>=10 and $age<18: $x=array(1=>array(17.5, 651),2=>array(12.2,746)); $y=1; break; case $age>=10 and $age <18: $x=array(1=>array(17.5,651),2=>array(12.2,746)); $y=0.95; break; case $age>=18 and $age<30: $x=array(1=>array(15.3,679),2 =>array(14.7,496)); $y=0.95; break; case $age>=30 and $age<60: $x=array(1=>array(11.6,879),2=>array(8.7,829)); $y=0.95; break; case $age>=60: $x=array(1=>array(13.5,487),2=>array(10.5,596)) ; $y=0.95; break; default: break; } return ceil(($x[$sex][0]*$weight+$x[$sex][1])*$y); //Round floating point numbers } These are the built-in parameters. Are the first two the default values? $weight=0,$sex=1,$age These two codes were modified to JS and encountered difficulties: case $age>=0 and $age <3:$x=array(1=>array(60.9,-54),2=>array(61.0,-51)); Who can help? As a favor, I will change it to Javascript, thank you. ——Solution—————— — JScript code function bmrs(weight,sex,age){ var x=new Array(2),y=null; switch(true) { case age>=0 && age=3 && age=10 && age=10 && age=18 && age=30 && age=60: x[1]=new Array(13.5,487),x[2]=new Array(10.5,596); y=0.95; break; default: break; } return Math.ceil((x[1][0]*weight+x[1][1])*y); }
Please tell me how to save data in php, thank you
Please tell me how to save data in php, thank you! My brother has a data query website, and the amount of data is expected to be large. I initially wanted to insert it into mysql for the convenience of query, but according to actual measurements, the amount of data inserted every day may be more than 100M. If the cost of using mysql is estimated to increase, it is not yet Know how efficient it is. So I want to save the data in the form of a file. I have considered txt and xml. Reading the file is a little troublesome but not a big deal. But I recently thought, can I use serialization to save it into a file? (Because my data essentially belongs to some array data), if it is all serialized and deserialized directly when reading, the efficiency should be much faster? I would like to hear the opinions of experts, thank you! ! ——Solution——————–Query reading The number of times should be orders of magnitude more than writing, right? If you don’t use files in the database, IO will consume the machine——Solution——————- –Only caching data that does not change frequently is meaningful, otherwise the overhead…
A question about PHP file reference, please help me take a look at it, thank you
A question about PHP file reference, please help me take a look, thank youA question about PHP, please help me take a look, I define a constant in index.php define(‘SCRIPT’,’index’); And reference the file title.php require ‘title.php’; In title.php, I did not reference the index.php file, but the values of the constants in index.php could be printed out normally echo SCRIPT; //Result index I would like to ask, can the referenced php file use the constants and variables in the referrer php file? Example: index.php references title.php, can title.php use the constants and variables defined in index.php? Share to: ——Solution——————–If you directly When browsing http://localhost/title.php, the index should not be printed. The printed value should be SCRIPT If you browse http://localhost/index.php at that time, it will be printed out and the value is index In fact, I personally copied the code directly based on my understanding! ——Solution——————–In require ‘title.php’; Previously defined global variables or constants can be accessed in title.php— —Solution——————–define(‘SCRIPT’,’index’); define defines global constants that can be accessed anywhere
How to use php to batch process mysql data? I hope the experts can provide the code directly, thank you
How to batch process mysql data using php? I hope the experts can provide the code directly, thank you! For example, there are several pieces of data in the database, and you want to insert the sum obtained by adding two fields in each piece of data into another field: cca ccb ccd id 45 66 0 1 67 36 0 2 86 24 0 5 76 84 0 8 6 55 0 12 …… The calculation for a single line is as follows: <?php require_once(“header.php”); $q=”select * from member where id=’5′”; $r=$obj_db->simplequery($q); $a=$obj_db->fetchRow($r,DB_FETCHMODE_ASSOC); $ccd=$a[cca]+$a[ccb]; $obj_db->simplequery(“update member set ccd=’$ccd’ where id=’5′”); ?> Is there any way to calculate each piece of data in batches at once? Please give the detailed code, thank you!——Solution——————————–$obj_db->simplequery(“update member set ccd=cca+ccb”);
In PHP, what is the difference between cookies and sessions, and what are the benefits of using them? (Please give me the answer, not Baidu, thank you)?
Reply content: Let’s not talk about session and COOKIE in Php. Let’s take a look at what session and COOKIE are in the normal web. COOKIE is actually a technology on the browser side. Since HTTP itself is stateless, generally speaking, the server does not know who is requesting each time. Therefore, a web session allows temporary storage of some content on the client through set-COOKIE in the HTTP header. The client needs Each HTTP request in this session is accompanied by the content of the current COOKIE (it will not be sent if COOKIE is disabled). Sessions here are generally defined by domain names. But COOKIE has two big flaws: 1. COOKIE is stored on the client, so COOKIE can be read, appropriated and modified. This means that if any key information, such as login information, is stored using COOKIE, others can read, delete, and modify it at will. 2. Other disguised sites may be able to directly obtain your COOKIE content. So how to access this information to make it difficult for the client to delete COOKIE at will to disguise other users? Generally speaking, there are two major types of methods: 1. Encrypt the COOKIE; 2. Only…
How does Goutte get the url in the a tag, or a useful PHP crawler library, thank you
How does Goutte get the url in the a tag? Or a useful PHP crawler library, thank you [], ‘link’ => [], ‘content’ => [], ‘source’ => [], ‘date’ => [], ]; public function __construct() { try { $this->_client = new Client(); $this->_crawler = $this->_client->request(‘GET’, ‘http://www.ningshan.gov.cn/Category_90/Index.aspx’); // $client->getClient()->setDefaultOption(‘config/curl/’.CURLOPT_TIMEOUT, 10); } catch (Exception $e) { throw new \Exception($e->getMessage(), 1); } } public function getDate() { $this->_crawler->filter(‘p#list>ul>li>span’)->each(function ($node) { $this->_news[‘date’][] = $node->text(); }); } public function getTitle() { $link = $this->_crawler->selectLink(‘Ningshan County held the 22nd Standing Committee of the Eighth CPPCC National Committee’)->link(); var_dump($link->getUri);die; $this->_crawler->filter(‘p#list>ul>li>a’)->each(function ($node) { if ($node->text() !== ‘Ningshan News’) { $this->_news[‘title’][] = $node->text(); $this->_news[‘link’][] = $node->link(); $this->_news[‘source’][] = ‘Ningshan News’; } }); } } //———————————- try { $spider = new Spider(); $spider->getDate(); $spider->getTitle(); echo json_encode($spider->_news, JSON_UNESCAPED_UNICODE); } catch (Exception $e) { echo $e->getMessage(); } Reply content: How does Goutte get the url in the a tag? Or a useful PHP crawler library, thank you [], ‘link’ => [], ‘content’ => [], ‘source’ => [], ‘date’ => [], ]; public function __construct() { try { $this->_client = new Client(); $this->_crawler = $this->_client->request(‘GET’, ‘http://www.ningshan.gov.cn/Category_90/Index.aspx’); // $client->getClient()->setDefaultOption(‘config/curl/’.CURLOPT_TIMEOUT, 10); } catch (Exception $e) { throw new \Exception($e->getMessage(), 1); } } public function getDate()…
PHP overseas recruitment, thank you, please don’t delete it, it is urgently needed
Job requirements: 1.Proficient in php, have at least two years of php development experience and be proficient Development under lampand wamp Work 2.Participated in the development of at least three projects, and participated in no less than a quarter of the development of each project Quantity 3.Proficiencymysqlandsqloptimization, or do not understand sql font>Optimized, but will not write too elementary sql statements 4.Have ever used non-relational databases or memory storage databases, such as mangodb or redisetc. 5.Able to use nativephpcode and common open source frameworks Agile development 6.Broad thinking and strong learning ability, able to quickly integrate into new projects and new teams 7.can usejquery, html/css and other front-end skill assistancephp 8.Familiar with linux, able to compile php proficiently, Installation and deployment of common software such as nginx 9.Love technology , the pursuit of technology is never-ending, the thinking is delicate, the communication is smooth, the code is clean, and the emphasis is on elegance Job responsibilities: 1.Develop Internet products according to the company’s business needs; 2.Improve and maintain the company’s existing products according to operational needs; 3.Provide technical support for the company’s business; 4.Conduct technical research and testing on new businesses; 5.Complete the tasks assigned by superiors and other related…